Well let's see:

(Bolded variables are vectors)

Newton's second law says that the force acting on a body is equal to the body's acceleration multiplied by it's mass.

**F** = m**a**

Hooke's law says that the force of a string is proportional to the distance the mass on the string is from the resting point (See below) by a factor k.

**F** = k**d**

Code:

o <- fixed point
\
\
\
o <- resting point
\ ¯\ distance from resting point
\ _\
o <- mass attached to spring

NOTE: Typically, Hooke's law is for 1-Dimensional objects and is written as

**F** = kx

however I suspect that you would rather use a 2-Dimensional spring, so we'll replace the 1-Dimensional variable, x, with a 2-Dimensional vector d, <x,y>.

Thus

**F** = m**a**

**F** = k**d**

Solving for a, the acceleration, we obtain:

**a** = k/m***d**

Oh BTW, k is the "springiness", or "stiffness" of the string, while m is the mass of the mass attached to the spring.

Though we could use ahab's vector library when applying this to Actionscript, I think we'll just break up the vector into components to apply this to ActionScript.

Code:

k = .1;
m = 1;
d = .95; // Uh.. Damping constant... Tell you about this later ;)
rest_x = 275;
rest_y = 200;
onEnterFrame = function(){
var dx = rest_x - m1._x; // Calculate distances
var dy = rest_y - m1._y;
var ax = k/m * dx; // Calculate the acceleration
var ay = k/m * dy;
vx += ax; // Add the Acceleration to the Velocity
vy += ay;
vx *= d; // Apply the damping factor to the velocity
vy *= d;
m1._x += vx; // Add the Velocity to the Mass' position
m1._y += vy;
}
onMouseDown = function(){
vx = 0;
vy = 0;
m1._x = _xmouse;
m1._y = _ymouse;
}

Make a clip, give it the instance name m1, and paste the code. Then click away!

I'll add to it later. Gravity, a moving resting point, etc. This is just a start. =\

Later,

Martin Muñoz