# hitTesting with array

**URL:** <https://forum.kirupa.com/t/hittesting-with-array/131210>\
**Category:** Uncategorized\
**Created:** [December 13, 2004, 4:47pm UTC](https://forum.kirupa.com/t/hittesting-with-array/131210 "2004-12-13T16:47:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![H4T](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/h4t/32/329_2.png) [@H4T](https://forum.kirupa.com/u/H4T)\
**Post date:** [December 13, 2004, 4:47pm UTC](https://forum.kirupa.com/t/hittesting-with-array/131210/1 "2004-12-13T16:47:16Z")

</div>

I have a simple FOR loop which runs through an array of MC names, which runs fine, but I’m trying to use these names inside this array as hittest values. So, I have one MC, and the code in this MC runs through an array and checks for any collisions between it and the mc in the array.

```auto
 for(k=0; k<herbNames.length; k++) {
if(name.hitTest(herbNames[k])) {
	trace(name+" hit "+herbNames[k]);
}
}

```

So, how should I do the hitTest? Here is my idea, but because of the size of the mcs involved, I don’t want to sit around all day waiting for the correct collisions to occur, lol. Here is what I had in mind…

```auto

if(name.hitTest(herbNames[k])) {
		trace("Collision!");
}

```

Would that work? Or…something else? Is there maybe a more effecient way to do this (maybe a FOR…IN loop?)?
