Hey voltron,

Sorry I didnt answer earlier but I must have missed this thread yesterday.

You problem is slightly tricky and involves a common problem experienced when dealing with rotation.

First off, I dont think trying to take the mouse rotations and using that with the hourhand's _rotation is going to work. One problem with that is that moving your mouse around the clock 360 degrees would mean that the position of the hour hand would be exactly where it was when you started (since the mouse rotation after 360 degrees is the same), however, what should really happen, is the hour hand should have moved 1-twelfth of a full rotation as it would have moved by 1 hour.

So instead of rotating the hour hand based on its relation to the mouse, we can rotate it based on how much the minute hand rotates, or more specifically, how much it rotates each time the mouse moves when its being dragged. Each time the minute hand moves, the hour hand should move 1-twelfth of that (1/12) - and thats not 1/60. Though there are 60 minutes in an hour, the rotation of a clock is based 12 hours. So 60 minutes (one full rotation of the minute hand) equals 1 hour which is 1/12 of a circle meaning the hour hand moves 1/12 the distance of the minute hand.

So first things first, we now need to know how much the minute hand moves each time its moved. We need a new variable for this. We can call it last_rotation.

ActionScript Code:

last_rotation = _rotation;

It saves the rotation of the minute hand since the last time it was moved (this assignment is set after the current rotation has been figured out so it will be used to compare for finding the next rotation) so we can compare it to the current rotation and find out how much it has changed.

ActionScript Code:

change_in_rotation = _rotation - last_rotation;

That change is then divided by 12 and added to the current rotation of the hour hand

ActionScript Code:

_parent.hourhand._rotation += change_in_rotation/12;

But wait! Here's the tricky part. Flash only recognizes rotation as being a value from -180 to 180. Nothing higher, nothing lower. So, when you move your minute hand around the clock a bunch of times, you arent going to get 170 degrees, 175 degrees, 180, 190, 200. Once it passes 180, its going back to -180 and will start back up from there. The problem is, what happens to the change_in_rotation when you make that jump? Consider moving from 175 to -180.

ActionScript Code:

change_in_rotation = _rotation - last_rotation;
// becomes
change_in_rotation = -180 - 175;
// which is
change_in_rotation = -355;

A change of -355 degrees is not the 5 degrees you actually moved. To correct this, a simple if-else can be used to check for large values for the change and correct it as needed by adding or subtracting 360. Here is the full script:

ActionScript Code:

// On the minute hand
on(press){
trace("minute");
dragging = true;
orig_mouse_angle = Math.atan2(_parent._ymouse-_y, _parent._xmouse-_x) * 180/Math.PI;
orig_rotation = _rotation;
last_rotation = _rotation; // save the last rotation when clicked
orig_x = _parent._xmouse;
this.gotoAndStop(2);
}
onClipEvent(mouseMove){
if(dragging){
curr_mouse_angle = Math.atan2(_parent._ymouse-_y, _parent._xmouse-_x) * 180/Math.PI;
_rotation = orig_rotation + curr_mouse_angle - orig_mouse_angle;
change_in_rotation = _rotation - last_rotation; // find change in rotation
// make sure change is reasonable and not a jump from - to + or vise versa
if (change_in_rotation > 180) change_in_rotation -= 360;
else if (change_in_rotation < -180) change_in_rotation += 360;
_parent.hourhand._rotation += change_in_rotation/12; // set hour rotation by 1/12 change for minute
last_rotation = _rotation; // remember the current rotation as new last rotation
updateAfterEvent();
}
}
on(release,releaseOutside){
dragging = false;
this.gotoAndStop(1);
}