type = 'application/x-shockwave-flash'
data = 'http://sitepointstatic.com/flash/follower.swf'
width = '400'
height = '400'
bgcolor = 'black'

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.

Georgina has more than fifteen years' experience writing and editing for web, print and voice. With a background in marketing and a passion for words, the time Georgina spent with companies like Sausage Software and sitepoint.com cemented her lasting interest in the media, persuasion, and communications culture.

Get your free chapter of Level Up Your Web Apps with Go

Get a free chapter of Level Up Your Web Apps with Go, plus updates and exclusive offers from SitePoint.

No Reader comments

Related books & courses
Available now on SitePoint Premium

Preview for $1