Flint Particle System Forum - how do i properly kill the emitter after the last particle dies? Wed, 24 Nov 2010 23:28:35 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher how do i properly kill the emitter after the last particle dies? http://flintparticles.org/forum/comments.php?DiscussionID=246&Focus=878#Comment_878 http://flintparticles.org/forum/comments.php?DiscussionID=246&Focus=878#Comment_878 Thu, 30 Jul 2009 22:13:13 +0100 firemaplegames
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 ]]>
how do i properly kill the emitter after the last particle dies? http://flintparticles.org/forum/comments.php?DiscussionID=246&Focus=887#Comment_887 http://flintparticles.org/forum/comments.php?DiscussionID=246&Focus=887#Comment_887 Thu, 06 Aug 2009 18:38:01 +0100 gspschmid
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;
]]>
how do i properly kill the emitter after the last particle dies? http://flintparticles.org/forum/comments.php?DiscussionID=246&Focus=888#Comment_888 http://flintparticles.org/forum/comments.php?DiscussionID=246&Focus=888#Comment_888 Fri, 07 Aug 2009 07:47:06 +0100 firemaplegames
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 ]]>