Arrays and for loops maybe?

I would’ve thought of a better title but I honestly have no idea what’s going on. I have this code on the main timeline:


dots = new Array();
for (i = 0; i < 10; i++) {
 attachMovie("dot", "dot" + i, i);
 _root["dot" + i]._x = Math.random() * 300;
 _root["dot" + i]._y = Math.random() * 300;
 dots.push("dot" + i);
}
len = dots.length;
distanceDetect = function () {
 for (j = 0; j < lean; j++) {
  usedDot = dots[j];
  //trace(usedDot);
  //returns dot0 through dot9
  //trace(usedDot._x);
  //returns undefined
  dx = _xmouse - usedDot._x;
  dy = _ymouse - usedDot._y;
  distance = Math.sqrt(dx * dx + dy * dy);
  if (distance < 100) {
   trace("NOW!");
  }
 }
};
onEnterFrame = distanceDetect;

The problem is when I try to find the x and y coordinates of the attached movie clips. Does anyone know what’s wrong with my script? Thanks :hoser:.