# Collision-detection between dynamically named movieclips

**URL:** https://forum.kirupa.com/t/collision-detection-between-dynamically-named-movieclips/111245
**Category:** Uncategorized
**Created:** [May 25, 2004, 5:07am UTC](https://forum.kirupa.com/t/collision-detection-between-dynamically-named-movieclips/111245 "2004-05-25T05:07:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![MrFlashALot](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MrFlashALot](https://forum.kirupa.com/u/MrFlashALot)
#### Post date: [May 25, 2004, 5:07am UTC](https://forum.kirupa.com/t/collision-detection-between-dynamically-named-movieclips/111245/1 "2004-05-25T05:07:34Z")

</div>

Hi there,

I have a movieclip (myMC) that I create several instances of.

I dont duplicate the movieclips, but just copy and rename them like “myMC\_i”, where “i” is a unique number.

Can I somehow check if one copy of myMC (for instance “myMC\_2”) collides with another copy (for instance “myMC\_5”), always ignoring collisions with other types of movieclips on the stage?

Thats the problem I cant solve. I can either check for a collision with ANY other movieclip, or check for a collision with a single SPECIFIED movieclip (by checking for its name).  
But I dont know how to check for a collision with a group of movieclips that has the first part of their names in common. If it had been like in a search-engine, you would have been able to search for:

myMC\_1.hitTest(“myMC\_” + \*);

…where the star (\*) is any number (or letter too, for that matter).

Sorry about the rant, but hope somebody still understands enough of what Ive said to help me.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 3:34pm UTC](https://forum.kirupa.com/t/collision-detection-between-dynamically-named-movieclips/111245/2 "2004-05-27T15:34:37Z")

</div>

Use a loop

```auto
for (var i = 0; i < 10; i++) {
    trace (my_MC.hitTest( this["myMC_" + i]) ) ;
}

```
