title: Actionscript 3 redrawing line on mouse move performance
body: <p>I'm refreshing my AS3 basic knowledge. Now I'm playing with creating movieclips with dimensions specified by mouse distance.</p>
  
  <p>This is my full code:</p>
  
  <p><a href="http://pastebin.com/4jpqFn7N" rel="nofollow">http://pastebin.com/4jpqFn7N</a></p>
  
  <pre><code>package  {
  
      import flash.display.MovieClip;
      import flash.display.Shape;
      import flash.display.Graphics;
      import flash.events.MouseEvent;
      import wck.World;
  
      public class Game extends World {
          private var isDragging:Boolean = false;
          private var line:Shape = new Shape();
          private var lineInfo:Array = [];
          public function Game() {
              addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
              addEventListener(MouseEvent.MOUSE_MOVE, recalcDrag);
              addEventListener(MouseEvent.MOUSE_UP, stopDragging);
          }
  
          private function addIt(dist:Number):void {
              var i:Rect = new Rect();
              i.x = mouseX;
              i.y = mouseY;
              i.width = dist;
              i.height = dist;
  
              addChild(i);
          }
  
          private function startDragging(e:MouseEvent):void {
              if(!(e.target is Rect)) {
                  isDragging = true;
                  lineInfo['bX'] = mouseX;
                  lineInfo['bY'] = mouseY;
                  line.graphics.moveTo(mouseX, mouseY); 
                  addChild(line);
              }
          }
  
          private function recalcDrag(e:MouseEvent):void {
              if(isDragging) {                
                  line.graphics.clear();
                  line.graphics.lineStyle(10, 0x000, .65);
                  line.graphics.moveTo(lineInfo['bX'], lineInfo['bY']); 
                  line.graphics.lineTo(mouseX, mouseY);
              }
          }
  
          private function stopDragging(e:MouseEvent):void {
              if(isDragging) {
                  var distance = DistanceTwoPoints(mouseX, lineInfo['bX'], mouseY, lineInfo['bY']);
                  line.graphics.clear();
                  isDragging = false;
                  if(!(e.target is Rect) &amp;&amp; distance != 0 ) addIt(distance);
              }
          }
  
          public function DistanceTwoPoints(x1:Number, x2:Number,  y1:Number, y2:Number): Number {
              var dx:Number = x1-x2;
              var dy:Number = y1-y2;
              return Math.sqrt(dx * dx + dy * dy);
          }
      }
  
  }
  </code></pre>
  
  <p>However I have feeling that redrawing whole line on mouse move might be resource expensive. How can I lighten it up a bit?</p>