This is a cool example of how to make a MovieClip follow the mouse, and “spring” to the mouse position.
Create a MovieClip on the stage and give it an instance name of ‘ball’
// two-dimensional springing example
// spring to mouse!
var spring:Number = 0.1;
var friction:Number = 0.85;
ball.x = 0;
ball.y = 0;
var vx:Number = 0;
var vy:Number = 0;
onEnterFrame = function() {
var ax:Number = (xmouse – ball.x) * spring;
var ay:Number = (ymouse – ball.y) * spring;
vx += ax;
vy += ay;
vx *= friction;
vy *= friction;
ball.x += vx;
ball.y += vy;
};
