Using a function and array to remove stage instances
I'm trying to figure out the best way to handle this.
I have an array of items I want to be looked through and removed if a specific function is running and if the stage contains them.
removalArray = [axScene, bridgeScene];
...
public function Removal(event:Event) {
trace("cheese");
for (var i:uint = 0; i>removalArray.length; i++) {
if (stage.contains(removalArray)) {
removeChild(removalArray);
removeEventListener(Event.ENTER_FRAME, Removal);
addEventListener(Event.ENTER_FRAME, CampScene);
} else {
removeEventListener(Event.ENTER_FRAME, Removal);
addEventListener(Event.ENTER_FRAME, CampScene);/**/
}
}
}
...
addEventListener(Event.ENTER_FRAME, Removal);
I'm able to get trace("cheese"); to work at its current position, but the function does not seem to like my "for" and "if" statements because putting trace("cheese") amongst them does not work.
As always, help is appreciated, and let me know if you need more info.
EDIT: Perhaps I should also note I am able to get
if (stage.contains(axScene)) {
removeChild(axScene);
} else if (stage.contains(bridgeScene)) {
removeChild(bridgeScene);
} else {
null;
}
to work correctly in that function.
EDIT2: Would this have something to do with addChild only being able to remove one instance at a time? I can't imagine that's it since this suppose to be run through a loop.