My function is supposed to check the collisions between the bullets and enemies, and for the first enemies, or so, it does. But then I get, “Error #1010: A term is undefined and has no properties. At Main.as:44.”
function checkCol()
{
for (var i = 0; i < EnemyList.length; i++)
{
for (var q = 0; q < BulletList.length; q++)
{
if (EnemyList[i].hitTestObject(BulletList[q]))
{
EnemyList[i].updateMe(BulletList[q].returnDamage());
if (EnemyList[i].returnHealth() <= 0)
{
if(this.contains(EnemyList[i]))
{
EnemyList[i].removeListeners();
this.removeChild(EnemyList[i]);
}
EnemyList.splice(i,1);
i--;
}
stage.removeChild(BulletList[q]);
BulletList.splice(q,1);
q--;
}
}
}
}
Line 44 is
if (EnemyList[i].hitTestObject(BulletList[q]))