Mouse Follower

Category : Flash Views : 10973
Version : 8 Rating
2.9/5 (26 votes)
Type : Text Source File: mouse-follower.zip
Result: See the result


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:
Free Flash Tutorials, Navigation, Interactive, Mouse Follower
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 Movie Clip 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 Movie Clip is going to move.
When Flash enters the frame we increase the Movie Clip’s position by the distance between the mouse and the Movie Clip, divided by the speed.

The Movie Clip is already moving towards the mouse, but let’s make the Movie Clip 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; }
This code will make the Movie Clip rotate depending on the direction and the speed he is "walking".
And just like the other speed, the bigger rotSpeed is the slower the Movie Clip will rotate.

I hope you liked this special effect and start using it on your movies.

del.icio.us digg it Reddit Stumble Upon Technorati




Supporters

Reseller Web Hosting