# How do i detect if there is a collision on an n array element?

**URL:** <https://forum.kirupa.com/t/how-do-i-detect-if-there-is-a-collision-on-an-n-array-element/321080>\
**Category:** Uncategorized\
**Created:** [April 10, 2011, 2:20am UTC](https://forum.kirupa.com/t/how-do-i-detect-if-there-is-a-collision-on-an-n-array-element/321080 "2011-04-10T02:20:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chilldog](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@chilldog](https://forum.kirupa.com/u/chilldog)\
**Post date:** [April 10, 2011, 2:20am UTC](https://forum.kirupa.com/t/how-do-i-detect-if-there-is-a-collision-on-an-n-array-element/321080/1 "2011-04-10T02:20:55Z")

</div>

hello…

If you have a group of movie clips stored in an array and the movie cliops are placed on the stage randomly, and use your arrow keys to move a box on top of one of the movie clips - how can you “tell” Flash which movie clip you clicked on?

Right now I’ve got a for loop going which loops through the array that has stored the movie clip instances, presumably the hitTestObject would eventually get a hit…But this doesn’t work, especially inside an event handler where when I press the right arrow on my keyboard.

```auto

if (event.keyCode == Keyboard.RIGHT) {
   box.x += 5;
   for (var i:uint = 0; i <= numberOfClips; i++) {
      if (box.hitTestObject(arrayOfMovieClips*);
         arrayOfMovieClips*.x += 5;
      }
   }
}

```
