# Using a For Loop with Hittest objects - I'm stuck!

**URL:** <https://forum.kirupa.com/t/using-a-for-loop-with-hittest-objects-im-stuck/328109>\
**Category:** flash\
**Created:** [April 19, 2012, 10:05pm UTC](https://forum.kirupa.com/t/using-a-for-loop-with-hittest-objects-im-stuck/328109 "2012-04-19T22:05:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![netmonkey](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@netmonkey](https://forum.kirupa.com/u/netmonkey)\
**Post date:** [April 19, 2012, 10:05pm UTC](https://forum.kirupa.com/t/using-a-for-loop-with-hittest-objects-im-stuck/328109/1 "2012-04-19T22:05:37Z")

</div>

Hi,  
I’m trying to get something quite simple to work, but can’t figure out what’s happening here. I have five identical MCs (Bat characters), and the user can drag a bottle to feed them.

There is a hittest object (called WormEat) inside the bat’s head. When the bottle, which is attached to the cursor touches the bat’s head, it toggles to frame 2 of the bottle, which should play an animation of the liquid going down to empty.

This code is all working fine, except that when the code toggles to frame 2 of the bottle, it remains static. The animated Movie Clip doesn’t play. Any ideas??

If not, perhaps a Switch statement could work, but I’m not sure how to use that method with Hittest…

Thanks,  
Matt

```auto
var DragArray:Array = [Bat1, Bat2, Bat3, Bat4, Bat5];
for (var i:int = 0; i < DragArray.length; i++) {
    
DragArray*.addEventListener(Event.ENTER_FRAME, CollisionWorm);
}

function CollisionWorm(event:Event) {
var Bats:MovieClip = MovieClip(event.currentTarget);
var index:int = DragArray.indexOf(Bats);

Bottle.x = mouseX;
Bottle.y = mouseY;

if (Bottle.BottleHit.hitTestObject(Bats.BatEat)) {
        
        Bottle.gotoAndStop("Empty");
        Bats.gotoAndStop("eat");
        
        } 

else {
    
Bottle.gotoAndStop("Full");
        
Bats.gotoAndStop("start");

}

}

```
