Okay, I’m searching the web and I can’t find an answer I can understand so here goes.
I have to arrays, they both hit detect against each other. When they detect a hit they each launch a method in the custom class as well as splice the entries out of the arrays. Now, I CAN NOT remove the child right their cause that causes them to immediately delete themselves from the stage, I need the death animation to play. I can’t remove them in the class cause it says it can only be removed from the caller.
So, WHAT is a caller, and how do I uh, find it and uh, call it. Example code.
for(var b=0; b<blastArray.length;b++){
for(var s=0; s<boxArray.length;s++){
if(blastArray**.hitTestObject(boxArray[s])){ //test if they hit each other
score += 5; //scoring and level completion
value1 += 1;
boxArray[s].die(); //death animations for both objects
blastArray**.hit();
boxArray.splice(s,1); //remove objects from arrays
blastArray.splice(b,1);
}
}
}
If I put removeChild(this) in the boxArray method .die, I get a 2025 error.
If I try parent.removeChild(this), I get, cannot access property of a null object. 1009 error.