ActionScript: Detect collision between 2 circles

With the Pythagoeran theorem you can detect collision with 2 circles.

You just have to get the rays of 2 circles with the width property divided by 2.
Actually the width property returns the diameter of the circle. So, you can calculte the ray like this:

ray = diamter / 2
ray = circle.width / 2

Therefore if you get the distance between the 2 circles you can detect the collision like this:

if distance < ( circle1.width/2+ circle2.width/2 ) is true => Collision

ActionScript: Get distance between 2 MovieClips

If you want to get the distance in pixels between 2 graphic objects just use the Pythagorean theorem in ActionScript :).

c² = a² + b²

Download source :