I have an array of objects that when another object hits one of them, the object will be removed. I have removed it from the stage using removeChild() and removed from the array using splice(), but somehow the object is still calling some of its functions which is causing errors. How do I completely get rid of an object? There are no event listeners tied to it either.
You need to make sure that the display object you're removing:
stage.removeEventListener(...) for any corresponding stage.addEventListener(...)Event.ENTER_FRAME eventsetInterval anywhereSo when you have removed the object with removeChild and removed it from the array you kept it in, also call its stop method to make sure it's not playing its timeline. It may also be a good thing to have a method on that object called something like halt, cleanup or finalize that unregisters any listeners, stops timers, timeouts, intervals, etc., clears references (i.e. sets the variables to null) to it's parent, the stage or any object that isn't going away too.
It sounds like you may be running into a garbage collection issue with the flash player.
A new API has been added to Flash Player 10 that should address this:
unloadAndStop()
Grant Skinner has more info on this on his blog: http://www.gskinner.com/blog/archives/2008/07/unloadandstop_i.html
You can grab a beta of Flash Player 10 at:
http://labs.adobe.com/technologies/flashplayer10/
mike chambers
[email protected]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With