Article

Home » Design and Layout » Flash Tutorials » Flash Script - Cursor Trick 2: Rotating Mouse Follower

About the Author

SitePoint

View all articles by SitePoint...

Flash Script - Cursor Trick 2: Rotating Mouse Follower

By SitePoint

April 28th, 2003

Reader Rating: 6.5

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.

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links

Rate This Article

  • 1
    Poor
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
    Great

Comment on This Article

Have something to say?

Post A Comment

You need to be a member of the SitePoint Forums to comment on this post. Sign Up

Already a member? Post using your SitePoint Forums account: