Without looking at the code, lets assume that every class has listeners. If you removeChild without removing the listeners you get this annoying error message.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Two nifty ways of getting rid of this message
addEventListener(Event.ENTER_FRAME, loop); function loop(event):void { if(isAlive == false) { removeEventListener(Event.ENTER_FRAME, loop); //remove other listeners } else { //loop function } }
OR
addEventListener(Event.ENTER_FRAME, loop); function loop(event):void { if(root == null) { removeEventListener(Event.ENTER_FRAME, loop); //remove other listeners } else { //loop function } }
Whats your favorite method?
Is there a different method?
What do you think are the pro's and con's of each method