Proximity

I wrote this action script to display the proximity of one object to another. The eventual idea is to use this as a variable in an interactive function, not just display it in a text box.

I seem to remember something that is already in flash that does this but I can’t remember what it is.

If there is a function that is already in flash that will detect this or a better (shorter) way to write this script, please let me know.

Here’s the script:


onEnterFrame = function () {
	// create the function that will read the proximity of ball 2 to ball 1
	xDiff = Math.abs(_root.ball1._x-_root.ball2._x);
	yDiff = Math.abs(_root.ball1._y-_root.ball2._y);
	prox = xDiff+", "+yDiff;
	// set the text box to read the proximity of ball 2 to ball 1
	_root.coords.text = prox;
};

Thanks,