This content has been marked as final. Show 4 replies
Garbage collector will not destroy your swf or any other object for that matter until all reference to it has been destroyed. This include events, so each time you add a listener to an object you are also adding a reference to the listening object.
This means that a polite object must remove its event listeners once it stop needing them, in your case I would add a REMOVED event listener to my SWF that will do the cleanup of all the listeners that this swf is using to the stage and any other object.
If i made something thats not supposed to be part of the application, but i still want to load it into my portfolio website.
I have to edit it first to make a remove listeners function??
There must be a way to work around this.
In flash 8 AS2 i never had problems with this and i could load just ANY swf file (maybe set it to _lockroot=true) and it worked!
Is there a way to create a automatic listener removal function?
Well you have to ways to go arround this:
You can remove the event listeners when you unload the movieclip from the SWFLoader, or you can impement an UNLOAD event listener in the containing SWFLoader or the stage, the UNLOAD event bubbles witch means that you'll be able to catch this event and remove the listeners. Still, you'll have to know witch events the swf has registered to, I haven't been able to find any function to know witch events a specific object is listening to. I don't think there is :(.
On the other hand any swf compiled with flash 8 or prev. shouldn't have this problem since it will work in a different virtual machine... still you wont be able to control them ether.
After some searching in the doc's and on internet i came to the same conculsion :(
This kinda sucks.......
Any way, Thx for your help!