Error #1010: A term is undefined and has no properties. when it is not even on the stage
This is an error that i cant even explain to myself why does it trigger, because it doesnt trigger every time - only when i shoot like the 1st or last ship of the Array and it somehow changes and it doesnt splice itself or something like that.
So i have a doShips Function:
function doShips() {
for (var i:int = shipArray.length - 1; i >= 0; i--) {
shipArray.moveDown() //what the code in the Ship and Ship2 class does -> only: this.y += 3
for (var bcount= _bulletsArray.length-1; bcount >= 0; bcount--) {
//if the bullet is touching the ship
if (shipArray.hitTestObject(_bulletsArray[bcount])) {
//if we get here it means there`s is a collision
removeChild(_bulletsArray[bcount]);
_bulletsArray.splice(bcount,1);
removeChild(shipArray);
shipArray.splice(i,1);
}
}
}
}
When i debug the FLA the error comes from
at ArrayOfShips_newG_withTurret_fla::MainTimeline/doShips()[ArrayOfShips_newG_withTurret_fla.MainTimeline::frame1:100]
line 100 is
if (shipArray.hitTestObject(_bulletsArray[bcount])) {
before that there is a Player on the stage that shoots bullets
//handling the bullets
function doBullets(){
//make a for loop to iterate all the _bulletsArray on the screen
for (var bcount:int = _bulletsArray.length-1; bcount>=0; bcount--) {
//make the bullets move Up
_bulletsArray[bcount].y -=20;
//if the bullet is beyond the screen remove from the stage and the Array
if(_bulletsArray[bcount].y < 0) {
removeChild(_bulletsArray[bcount])
_bulletsArray.splice(bcount,1);
}
}
}
also a function to move the player in the X coordinate.
and also a function that positions the ships,but they are not important because i dont think they have anything to do with the error.
I can show all the code of the FLA if that is going to help somehow to solve this.
