Mouse Following Actionscript ?'s

Hi,

I got a script running that rotates an image depending on where the mouse is in the movie…

[AS]
a = sun._y-_ymouse;
b = sun._x-_xmouse;
angleA = Math.atan2(a, b);
degrees = angleA/(Math.pi/180);
setProperty (“sun”, _rotation, degrees);
[/AS]

I want this movement to ease… maybe using the speed= command? But cant figure out how to do it… I also would like the image to rotate at a slow pace on its own even if the mouse isnt in the movie to follow.

I can post the .fla if you need it.
Thanks a bunch!

i think that give the movie clip an instance name and link the action with the instance. that’s how other mouse follower’s work !

umm… i dont understand.

[AS]
a = sun._y-_ymouse;
b = sun._x-_xmouse;
angleA = Math.atan2(a, b);
degrees = angleA/(Math.pi/180);
sun._rotation = degrees;
sun._x += (_root._xmouse-sun._x)/5;
sun._y += (_root._ymouse-sun._y)/5;
[/AS]

Try that. And setProperty is old, use the new dot syntax :wink: (example in my code)

sun._x += (_root._xmouse-sun._x)/5;
sun._y += (_root._ymouse-sun._y)/5;

These lines to be run onEnterFrame btw. _xmouse and _ymouse are the final positions of the clip, you subtract the current _x or _y position to get the different and 5 is the speed it travels (the higher the number the slower the speed) because it gradually divides by the position which makes it ease.

Heres a tutorial on mouse following with easing…

http://www.kirupa.com/developer/mx/followease.htm

Lostinbeta…
Thanks for the code…
I tried what you suggested, but it did not make the desired effect. Instead of the rotation being eased, the whole MC follows around my cursor.

Maybe you could look at it for me if you have some time…
Thanks, I appreciate it!

[AS]a = sun._y-_ymouse;
b = sun._x-_xmouse;
angleA = Math.atan2(a, b);
degrees = angleA/(Math.pi/180);
var diffAngle = degrees - sun._rotation ;
sun._rotation += diffAngle/5 ;[/AS]pom :phil:

Wow i’m stupid, I misread the question :stuck_out_tongue:

hey yeah this is cool

ahh, thanks pom!

just what i was looking for.

Thank you all for helping me out

hmm… i spoke too soon. heh

Ok, it looks good and it does what its suppose to except when it gets to a certain point in the rotation. For me, the right side of the image, the sun will stop following the mouse and then spin all the way around in the opposit direction to catch up with it on the other side.
Sounds kinda confusing so I attached the fla…
Is there any way to defeat this?

Thanks