Flash Script – Cursor Trick 2: Rotating Mouse Follower

By Georgina Laidlaw
We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now


Download the sample files here.

1. First, create a movieclip of your choice. Give the movieclip an instance name — I called mine ‘follower’.

3. In the first frame, insert the following action:

//sets the speed of rotation 
rotation_speed = 5;
//sets the elasticity the higher the value the higher the elasticity
elasticity = .1;
_root.onEnterFrame = function()
{
 with (follower) {
   _rotation += rotation_speed;
   _x += (_root._xmouse-_x)*elasticity;
   _y += (_root._ymouse-_y)*elasticity;
 }
};

That’s it! Test the movie. Remember, you can increase the rotation_speed variable to create different effects.

The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now
Login or Create Account to Comment
Login Create Account