In the example the first ball is always following the mouse pointer. We need a function that can be used in the example and any other in the future. So here we go!

function followMouse(mc, lowerDistance) { orig = {x:mc._x, y:mc._y}; dest = {x:_root._xmouse, y:_root._ymouse}; myAngle = Math.atan2((orig.y-dest.y), (orig.x-dest.x)); myDistance = Math2.distanceBetween(orig.x, orig.y, dest.x, dest.y)-lowerDistance; if (myDistance+lowerDistance>=lowerDistance) { mc._x -= Math2.cos(myAngle)*(myDistance/reductionMultiplier); mc._y -= Math2.sin(myAngle)*(myDistance/reductionMultiplier); } }


This function needs two arguments:
1- A movieclip (mc), this is the movie that will follow the mouse.
2- How far the movie can be from the cursor? (lowerDistance), in pixels.

Then, we have two points with their coordenates (the movie x and y, and the mouse x and y).
The angle calculation is using Math.atan2 method that calculates the cuadrant for you. 
We also need to know the distance between both points, here is when we use the Math2 class, by calling the distanceBetween method.

Finally if the distance is higher than the lowerDistance, we need to move our movie along the angle we have calculated with our distance. In the X axis we use Math.cos, in the Y, Math.sin. Note, if you increase the reductionMultiplier, movement will be slowly.