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

  1.  
    Hello!

    First of all, FLINT is awesome! Thank you so much!

    I have been trying to figure this out, but I cannot figure out how to do this properly...

    My situation is this:

    I have an emitter animating across the stage, it is emitting "fairy dust" as it travels.

    Its counter is set to 'steady'.

    When the emitter reaches its destination, I tell its counter to stop emitting by calling counter.stop();
    This works fine.

    What I can't figure out is how to remove/kill the emitter and the renderer from memory when the last particle fizzles out.

    Any help is appreciated.

    Best,
    Joe
    • CommentAuthorgspschmid
    • CommentTimeAug 6th 2009 edited
     
    You could just go with removing the emitter from the renderer (which might actually be superfluous) and then removing the renderer from the display object it was added to. Finally, you would set any references to the renderer and the emitter you had to null, after which the garbage collector will take care of the actual object-deletion.

    var e:Emitter2D = m_psEmitter = new Emitter2D();
    (...)
    e.start();
    e.runAhead(3.0);

    var r:DisplayObjectRenderer = m_psRenderer = new DisplayObjectRenderer();
    r.addEmitter(e);
    addChild(r);

    (.....)

    m_psRenderer.removeEmitter(m_psEmitter);
    //delete m_psEmitter;
    m_psEmitter = null;
    removeChild(m_psRenderer);
    //delete m_psRenderer;
    m_psRenderer = null;
  2.  
    Hello!

    Thanks for getting back to me!
    I actually just found the answer a few hours ago:

    e.addEventListener( EmitterEvent.EMITTER_EMPTY, removeMe );

    First I stop the emitter's counter, which will eventually trigger the EMITTER_EMPTY event.

    And like you said, I remove the emitter from the renderer in the removeMe function...
    And clean up everything else there as well.

    The problem I was having before was that I didn't know how to tell when the last particle fizzled out.

    It's working great, now. Thanks!

    Joe