The Garbage Collector in AS3 is smart, but it’s driving me crazy.
Being new to AS3, I didn’t realise that removing a child from the display list does not kill all it’s listeners, sounds, and some other stuff I don’t know.
When it affected me, I stopped for a moment and thought why is it built this way. It is true that sometimes, after removing a child from the display list, you do want the listener to stay.
Yet, I don’t see why they didn’t create another function that lets user kill all listeners in a particular child before removing it.
Anyway, after being stuck at this problem for a few agonizing hours, I realised all I need to do, is actually create a if statement inside any listener I want to kill as well, that if it’s parent is already null, i.e. to say it is already removed, then it should kill itself!
A simple solution. Hopefully no new bugs turn up after implementing this as a solution. Keeping my fingers crossed.
If this post helped you in any way, help me in return by clicking on the ad below:
Yes – the garbage collector can be tricky.
If you havent already I highly recommend reading Grant Skinners post on the subject.
http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html
Josef
U can try use System.gc(); function to send yout ‘trash’ to garbage collector and say: “hey garbage, delete it please man” and be happy
will speed up the content burn
the problem was that GC was thinking the object I had was still in use. hence, the automatic running of the default GC was not cleaning it.