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²

[swf:/wp-content/uploads/2010/11/Get_Distance.swf 550 400]

Download source : Get_Distance.zip

function getDistance(pObj1:MovieClip,pObj2:MovieClip):Number {
	var distX:Number = pObj1.x - pObj2.x;
	var distY:Number = pObj1.y - pObj2.y;
	return Math.sqrt(distX * distX + distY * distY);
}