title: Actionscript 3, rotate object on drag
body: <p>I have an object I need to rotate by clicking and dragging. Following some AS2 code I got the object to rotate a bit every time the mouse is clicked, but can't get it to work with drag.</p>
  
  <pre><code>needle.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
  stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
  
  function fl_ClickToDrag_2(event:MouseEvent):void
  {
  
          var angle = Math.atan2(mouseY-needle.y,mouseX-needle.x);
          // apply rotation to handle by converting angle into degrees
          needle.rotation = angle*180/Math.PI;
          // rotate the grip opposite the handle so it won't rotate along with it
          //this.grip._rotation = -this._rotation;
  }
  
  function fl_ReleaseToDrop_2(event:MouseEvent):void
  {
      needle.stopDrag();
  }
  </code></pre>