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?
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.