Here's another example exploring what can be done:

https://www.dropbox.com/s/4o28kqq4b30pb ... .capx?dl=1

/examples34/spring.capx

I commented it a lot and in many ways it's cleaner than what I've done before. I'm figuring it out as I go and unfortunately it would be too lengthy of a tutorial for me to write. Math used is some simple physics such as:

distance = speed* time

speed = acceleration * time

acceleration = force*mass

spring_force = -spring_constant * displacement

damping_force = -damping_constant * relative_velocity

Also vectors are used. addition, subtraction and dot product.

The dot product is used to get the speed in a certain direction.

Some simple trig is used too.

x = radius*cos(ang)

y = radius*sin(angle)

The collision detection uses the dot product to get the distance from a line. Otherwise everything is a mix of that.

There are two unsolved things in this:

1. The spring mesh can be made to fold in on itself.

2. The balls can teleport through walls if either are going fast enough.