# I want to use hitTestObject on all instances of a movieclip

**URL:** <https://forum.kirupa.com/t/i-want-to-use-hittestobject-on-all-instances-of-a-movieclip/297120>\
**Category:** Uncategorized\
**Created:** [September 25, 2009, 9:30pm UTC](https://forum.kirupa.com/t/i-want-to-use-hittestobject-on-all-instances-of-a-movieclip/297120 "2009-09-25T21:30:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gatita33](https://avatars.discourse-cdn.com/v4/letter/g/a698b9/32.png) [@gatita33](https://forum.kirupa.com/u/gatita33)\
**Post date:** [September 25, 2009, 9:30pm UTC](https://forum.kirupa.com/t/i-want-to-use-hittestobject-on-all-instances-of-a-movieclip/297120/1 "2009-09-25T21:30:00Z")

</div>

Hi, I’m trying to make a simple maze game. I have movement working, and now I’m trying to implement collision. Here’s what I have:

An 8x8 grid, with walls of length 1 to break the grid up into a maze.  
the walls are instances of a movieclip I’ve named “mc\_wall”  
a guitar-pick-shaped chip I’ll control the movement of  
a cross-hair called “arms” that will check if there are walls immediately surrounding my chip by way of collision.  
“arms” is a movieclip made up of four individual movieclips: “uparm”, “leftarm”, “rightarm”, and “downarm”

I have currently named each instance of “mc\_wall” to be “wall”  
this is the code I have now (using only right as an example):

function moveRobot(event:KeyboardEvent):void  
{  
doslide = true;  
if (event.keyCode == Keyboard.RIGHT)  
{  
if (arms.getChildByName(“rightarm”).hitTestObject(wal l) == true)  
{  
doslide = false;  
}  
}

```
    if(doslide == true)
    {
         slide = new Tween(robot, "x", None.easeNone, chip.x, chip.x + 30, 0.5, true);
         arms.x = arms.x + 30;
    }

```

}

this will work, causing the chip to remain in place if the rightarm detects “wall”, and move if the rightarm does not detect “wall”.  
My problem is that, although I have named every instance of “mc\_wall” to be “wall”, the only “wall” flash will recognize is the last one.

Is there a way to adjust this code to look at all 70-or-so instances of “mc\_wall” instead of only the last one?
