Mouse angle for math gurus...?

Hi guys,

I’m havin’ some problems adjusting a mouse angle script I found here on this forum.

I have a function that shows/hides 40 images depending on mouse direction (left/right), this is triggered only when I use an onPress action on a movieclip.

Instead of registrering left/right motion I’d like them to change depending on the angle of the mouse, but still only when the MC is OnPressed. Need the stage to be devided into 40 (360 degrees/40) so it has a smooth spin.

Heres the script:
[AS]
spd = 10;
onEnterFrame = function(){
targetAngle = Math.floor(Math.atan2(_ymouse - compass._y, _xmouse - compass._x) * (180 / Math.PI));
currentAngle = compass._rotation;
angleComp = targetAngle - currentAngle;
angleSignal = angleComp/Math.abs(angleComp);
moveDirection = ((angleComp >= 180) || (angleComp <= -180)) ? -angleSignal : angleSignal;
compass._rotation += spd * moveDirection;
if(Math.abs(angleComp) < spd){
compass._rotation = targetAngle;
}
}
[/AS]

This has some kind of ease when you move the mouse faster, don’t want that, but think this is the thing I need…

Anybody who can help me modify it!?!

Thanx in advance :slight_smile:

Hi,

I am using code given here but its not working. the co-ordinate for moving object is constact and hence the rotation is stopped at particular loaction. below is code

targetAngle = Math.floor(Math.atan2(_ymouse -mc_01._y, _xmouse -mc_01._x) * (180 / Math.PI));

I am rotating mc_01. after rotation also the coordinate remains same.

Let me know how can I solve this.

Thanks in Advace.