# Detecting multiple instances of a MC

**URL:** <https://forum.kirupa.com/t/detecting-multiple-instances-of-a-mc/304026>\
**Category:** flash\
**Created:** [January 31, 2010, 10:15am UTC](https://forum.kirupa.com/t/detecting-multiple-instances-of-a-mc/304026 "2010-01-31T10:15:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thedark\_master](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@thedark\_master](https://forum.kirupa.com/u/thedark_master)\
**Post date:** [January 31, 2010, 10:15am UTC](https://forum.kirupa.com/t/detecting-multiple-instances-of-a-mc/304026/1 "2010-01-31T10:15:44Z")

</div>

Ok so I want to do a collision detection for a bunch instances of a single movie clip. So I got this movieclip called “map1”. Inside “map1” there are a bunch of rectangles called “house1”. I also have a character whose name is mainChar1. So I know how to do the collision detection for each house individually, but i need a way to do it with some kind of a LOOP because there are like 50 houses. So instead of going through the code and doing house1, house2, house3… how do i do a loop for it? Here is the code for my collision detection:

[AS]  
if (map1.house1.hitTestPoint(mainChar1.x, mainChar1.y, true))  
{

```
            map1.y = map1.y-speedy;
            map1.x = map1.x-speedx;
            
            
        }[/AS]
```
