# Rotation mouse follow

**URL:** <https://forum.kirupa.com/t/rotation-mouse-follow/295405>\
**Category:** flash\
**Created:** [August 29, 2009, 4:50pm UTC](https://forum.kirupa.com/t/rotation-mouse-follow/295405 "2009-08-29T16:50:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ransom1337](https://avatars.discourse-cdn.com/v4/letter/r/e68b1a/32.png) [@Ransom1337](https://forum.kirupa.com/u/Ransom1337)\
**Post date:** [August 29, 2009, 4:50pm UTC](https://forum.kirupa.com/t/rotation-mouse-follow/295405/1 "2009-08-29T16:50:04Z")

</div>

Hello,  
I’ve put together some code to allow the user to rotate a clock hand around the clock by dragging it round. My code isn’t working and I was wondering if anyone could take a look at it and see what I’m doing wrong. The part which is the calculation of the mouse position and the clock hand rotation is code I found from another tutorial but I’m not sure if it’s AS2 or not, so maybe that’s where I’ve gone wrong?

```auto
onClipEvent (mouseDown) {
 if (this.hitTest(_root._xmouse, _root._ymouse)) {
   arrowDrag = true;
 }
}
onClipEvent(mouseMove) {
 if (arrowDrag == true) {
  var coordy1 : Number = _ymouse - this._y;
  var coordx1 : Number = _xmouse - this._x;
  var angleRadians1 : Number = Math.atan2(coordy1,coordx1);
  var angleDegrees1 : Number = angleRadians1 * 180 / Math.PI;
  this.rotation = angleDegrees1;
 }
}
onClipEvent(mouseUp) {
 arrowDrag = false;
}

```

Thanks.
