# HitTesting between two arrays of differing length

**URL:** <https://forum.kirupa.com/t/hittesting-between-two-arrays-of-differing-length/287726>\
**Category:** Uncategorized\
**Created:** [May 5, 2009, 5:20pm UTC](https://forum.kirupa.com/t/hittesting-between-two-arrays-of-differing-length/287726 "2009-05-05T17:20:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SonOfChaos](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@SonOfChaos](https://forum.kirupa.com/u/SonOfChaos)\
**Post date:** [May 5, 2009, 5:20pm UTC](https://forum.kirupa.com/t/hittesting-between-two-arrays-of-differing-length/287726/1 "2009-05-05T17:20:05Z")

</div>

Another, yes another problem. I’m just learning so I’m sure I’m making many stupid errors. How do you hitTest 2 separate arrays of different lengths, all entries against one another . Code below for guidance.

```auto

package{
    import flash.display.*;
    import flash.events.*;

   public class ArrayCompare{
         public var enemyArray:Array = new Array();
         public var bulletArray:Array = new Array();
       public function ArrayCompare(){
           
          for(var i:int = 0; i<3; i++){ //this populates enemyArray
              enemyArray.push*;
              //create a child, place on stage stuff etc.
          }
          for(var i:int = 0; i<5; i++){ //this populates bulletArray
             bulletArray.push*;
             /create child, place moving on stage stuff etc.
          }
 addEventListener(Event.ENTER_FRAME, collision); //stage listener to test collision
       }
      public function collision(){ //needs to test entire array, 
          if(bulletArray*.hitTestObject(enemyArray*)){ //against entire array of 
                    trace('hit!!!'); //different length
          }
      }
   }
}

```
