The mouse follower is a simple effect that can be used in almost anything, its one movie clip that will follow your mouse around.
The first thing to do is create the movie clip that will be following your mouse.
When you create it make sure it is positioned like this:
You can select your drawing and press "Ctrl + 2" then "Ctrl + 5" and Flash will center it automatically.
Now drag your movie clip to the stage, right click it and select Actions.
Paste this code:
| onClipEvent (load)
{ this._x = 0; this._y = 0; var speed = 20; } onClipEvent (enterFrame) { _x += (_xmouse - _x)/speed; _y += (_ymouse - _y)/speed; } |
On load we set this MC position to be equal to the mouse and the speed to 20.
Those speeds work a little different, the bigger they are the slower the MC is going to move.
When Flash enters the frame we increase the MC's position by the distance between the mouse and the MC, divided by the speed.
The MC is already moving towards the mouse, but let's make the MC rotate now.
|
onClipEvent (load)
{ this._x = 0; this._y = 0; var speed = 20; var rotSpeed = 5; } onClipEvent (enterFrame) { _x += (_xmouse - this._x ) / speed; _y += (_ymouse - this._y) / speed; _rotation += (((_xmouse - this._x) / rotSpeed) + ((endY - this._y) / rotSpeed)) / 2; } |
his code will make the MC rotate depending on the direction and the speed he is "walking".
And just like the other speed, the bigger rotSpeed is the slower the MC will rotate.
I hope you liked this special effect and start using it on your movies.




