# Drag and rotate problem

**URL:** <https://forum.kirupa.com/t/drag-and-rotate-problem/282542>\
**Category:** flash\
**Created:** [February 23, 2009, 3:54pm UTC](https://forum.kirupa.com/t/drag-and-rotate-problem/282542 "2009-02-23T15:54:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![izikon](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@izikon](https://forum.kirupa.com/u/izikon)\
**Post date:** [February 23, 2009, 3:54pm UTC](https://forum.kirupa.com/t/drag-and-rotate-problem/282542/1 "2009-02-23T15:54:55Z")

</div>

I have this swf that written in AS2  
[http://www.knowingames.com/test\_ik\_06.swf](http://www.knowingames.com/test_ik_06.swf)

```auto
if (stage.mouseX == _lastMouseX && stage.mouseY == _lastMouseY) {
    return;
   }
   var dX:Number = stage.mouseX - _myClip.x;
   var dY:Number = -(stage.mouseY - _myClip.y);
   var angleRad:Number = - (Math.atan2(dY, dX) + Math.atan2(_offsetX, _offsetY));
   _myClip.rotation = angleRad * 180 / Math.PI + 90 ;
   //trace(drizzler.rotation);
   var dxX:Number = (_offsetX*Math.cos(angleRad) - _offsetY*Math.sin(angleRad));
   var dyY:Number = (_offsetX*Math.sin(angleRad) + _offsetY*Math.sin(Math.PI/2 - angleRad));
  
_myClip.x = stage.mouseX - dxX;
   _myClip.y = stage.mouseY - dyY;
   
   _lastMouseX = stage.mouseX;
   _lastMouseY = stage.mouseY;

```

this \_offsetX and \_offsetY is where you pressing with the mouse  
does anyone have idea why it doesn’t working in AS3?  
or have an exmple for rotate and drag phisycs
