title: Pulling a bowstring [Flash as3]
body: <p>I've picked up some action scripting lately and I decided to make myself a simple bow and arrow game. So far I've made the arrow fly in an arced way. So up next is making my bow and being able to actually pull the string.</p>
  
  <p>So far I figured I would draw the bow as an MC and use a graphic to draw the string.
  I'm at the point where I should actually pull the string and I've got no clue how to advance from here. Any advice would be very appreciated. </p>
  
  <p>If possible just give me a pointer i would like to code the thing myself, I'm not asking for a finished result.</p>
  
  <p>Code:</p>
  
  <pre><code>package  {
  
      import flash.display.MovieClip;
      import flash.display.Shape;
      import flash.display.Stage;
      import flash.events.MouseEvent;
  
  
      public class bow extends MovieClip {
          var myStage:Stage;
          var bowString:Shape;
          var bowStringMc:MovieClip;
  
          public function bow(stageRef) {
              this.myStage = stageRef;
  
              myStage.addChild(this);
              this.x = myStage.stageWidth / 2;
              this.y = myStage.stageHeight / 2;
  
              this.drawBowstring();
          }
  
          public function drawBowstring() {
              bowString   = new Shape();
              bowStringMc = new MovieClip();
  
              bowStringMc.addChild(bowString);
              myStage.addChild(bowStringMc);
  
              bowString.graphics.lineStyle(2, 0x000000);
              bowString.graphics.curveTo(-50,this.height/2,0,(this.height-10));
  
              bowStringMc.x = this.x-1;
              bowStringMc.y = this.y - this.height / 2 + 5;
  
              bowStringMc.addEventListener(MouseEvent.MOUSE_DOWN, pullBowstring);
          }
  
          public function pullBowstring(e:MouseEvent) {
              // Have to start redrawing the graphic i gess but how?
          }
      }
  
  }
  </code></pre>
  
  <h1>Update</h1>
  
  <p>Thx vvMINOvv &amp; Slomojo, both answers helped me!
  I currently have 2 lines which are graphics i redraw when the bow is pulled back.</p>
  
  <p>If anyone else want to see how i did it, heres a rough snipped:</p>
  
  <pre><code>    public function drawBowstring() {
          bowStringTop    = new Shape();
          bowStringBottom = new Shape();
          bowStringMc     = new MovieClip();
  
          bowStringMc.addChild(bowStringTop);
          bowStringMc.addChild(bowStringBottom);
  
          myStage.addChild(bowStringMc);
  
          bowStringTop.graphics.lineStyle(2, 0x000000);
          bowStringTop.graphics.moveTo(0, 0);
          bowStringTop.graphics.lineTo(0, this.height / 2);
  
          bowStringBottom.graphics.lineStyle(2, 0x000000);
          bowStringBottom.graphics.moveTo(0, this.height-10);
          bowStringBottom.graphics.lineTo(0, this.height / 2);
  
          bowStringMc.x = this.x-1;
          bowStringMc.y = this.y - this.height / 2 + 5;
  
          this.hand.addEventListener(MouseEvent.MOUSE_DOWN, pullBowstring);
      }
  
      public function pullBowstring(e:MouseEvent) {
          myStage.addEventListener(MouseEvent.MOUSE_MOVE, reDrawBowstring);
          myStage.addEventListener(MouseEvent.MOUSE_UP, releaseBowstring);
      }
  
      public function releaseBowstring(e:MouseEvent) {
          myStage.removeEventListener(MouseEvent.MOUSE_MOVE, reDrawBowstring);
          myStage.removeEventListener(MouseEvent.MOUSE_UP, releaseBowstring);
      }
  
      public function reDrawBowstring(e:MouseEvent) {
          if (this.hand.x &lt; -18 || this.hand.x &gt; 0) {
              this.releaseBowstring(e);
          }
          this.hand.x = mouseX;
          this.arrow.x = mouseX;
  
          bowStringTop.graphics.clear();
          bowStringBottom.graphics.clear();
  
          bowStringTop.graphics.lineStyle(2, 0x000000);
          bowStringTop.graphics.moveTo(0, 0);
          bowStringTop.graphics.lineTo(this.hand.x, (this.height / 2)-5);
  
          bowStringBottom.graphics.lineStyle(2, 0x000000);
          bowStringBottom.graphics.moveTo(0, this.height-10);
          bowStringBottom.graphics.lineTo(this.hand.x, (this.height / 2)-5);
      }
  </code></pre>