Fork me on GitHub
Not signed in (Sign In)

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

    • CommentAuthorKenny
    • CommentTimeApr 8th 2009
     
    I'm working on a fireworks effect and everything goes as planned except as I let it run for a few times it starts to run really slow, sometimes even crashing my IDE. Is the following code not enough to destroy everything or am I missing something else?

    This is the code I have on an EMITTER_EMPTY call back:

    var emitter:Emitter2D = Emitter2D(e.target);
    emitter.stop();
    emitter.removeEventListener(EmitterEvent.EMITTER_EMPTY, next);

    Thanks,
    Kenny
    • CommentAuthorKenny
    • CommentTimeApr 9th 2009
     
    Problem solved. Just had to remove all the actions and filters from Emitter and PixelRenderer.
    • CommentAuthorRichard
    • CommentTimeApr 10th 2009
     
    Clearing all references to the emitter would possibly have been enough - then the garbage collector can remove it from memory.

    emitter.stop();
    emitter.removeEventListener(EmitterEvent.EMITTER_EMPTY, next);
    renderer.removeEmitter( emitter );
    emitter = null;


    If you also want to dispose of the renderer you'd need to remove references to this too.

    removeChild( renderer );
    renderer = null;