# Arrays and for loops maybe?

**URL:** <https://forum.kirupa.com/t/arrays-and-for-loops-maybe/162541>\
**Category:** flash\
**Created:** [September 14, 2005, 7:18am UTC](https://forum.kirupa.com/t/arrays-and-for-loops-maybe/162541 "2005-09-14T07:18:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [September 14, 2005, 7:18am UTC](https://forum.kirupa.com/t/arrays-and-for-loops-maybe/162541/1 "2005-09-14T07:18:47Z")

</div>

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:

```auto

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:.
