I know it's and old post, but this script really help me.
Also:
you can solve the problem for the constant check of far MC, with some modifications:
onClipEvent (load) {
searchRadius = 0;
distance = 0;
xDist = 0;
yDist = 0;
}
onClipEvent (enterFrame) {
searchRadius = searchRadius+10; // change here
for (i=0; i<10; i++) {
xDist = _x-_root["ball"+i]._x;
yDist = _y-_root["ball"+i]._y;
distance = Math.sqrt(Math.pow(xDist, 2)+Math.pow(yDist, 2));
if (distance<searchRadius) {
searchRadius = distance;
trace(i); //and now it will trace always just nearest (always)
}
}
}
So now instead of every frame check from a radious of 1000 to less, it will check from 0 to up. (increasing the radious until it found something, then it just change for an interval of 10)
Great code vengeance
sorry all for the bad english