# This for array colllision function doesn't work with anything but first object in array [closed]

For some reason, this simple simple loop is totally broken. (characterSheet is my character Class, it's just a movieClip with some extra functionality) (hitBox, is basically a square movieclip)

Anyway: every time hitBox make contact with a characterSheet in a different order than they were created: Nothing happens. The program only seems to be listening to collisions that are made with o2[0]. As soon as another hitBox is created, it pushes the last one out of o2[0] and the last one becomes totally useless. What's super weird is that I can hit characterSheets in any order I like....

    public function collisions(o1:Array, o2:Array)
{
if((o1.lenght>=0)&&(o2.length>=0)){
for (var i = 0; i < o1.length; i++)
{
var ob1 = o1[i];
for (var f = 0; f < o1.length; f++)
{
var ob2 = o2[f];

if (ob1 is characterSheet)
{   if (ob2.hitTestObject(ob1))
{
var right:Boolean = true;
if (ob1.x < hitBox(ob2).origin.x)
right = false;
characterSheet(ob1).specialDamage(hitBox(ob2).damageType, hitBox(ob2).damage, right);
}}}}}}


Also it might be somewhat helpful to see the function for creating a new hitBox

    public function SpawnHitBox(targeted, following, atype, xoff, yoff, ... args)
{
var newHitBox = new hitBox(targeted, following, atype, xoff, yoff, args);

• Should it be for (var f = 0; f < o2.length; f++)... just skimmed the code, that seemed to stand out. If there is only one object in o1 array, then you will get a single collision only – Samaursa Apr 5 '12 at 2:18
I think it should be: for (var f = 0; f < o2.length; f++)... just skimmed the code, that seemed to stand out. If there is only one object in o1 array, then you will get a single collision only