Search code examples
actionscript-3flash-ide

Cleanup After An Instance Has Left The Scene?


Do I have to worry anymore about all the listeners and class instances added to a movie clip that is no longer displayed on the scene?

I'm asking because I want to know if it makes sense to clean up after I'm done with a movie clip's instances on the scene.


Solution

  • Yes, you need to clean up.

    Event listeners will keep the clip from being garbage collected if they are not removed.
    Alternately, you can use weak event listeners. Then the listener will not prevent garbage collection as long as all other references to the clip are removed.

    AS3: Weakly Referenced Listeners