Rotation follow cursor help
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.
Code:
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.