Flint Particle System Forum - Ah another error with emitters Wed, 17 Nov 2010 12:05:44 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Ah another error with emitters http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=484#Comment_484 http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=484#Comment_484 Mon, 10 Nov 2008 07:06:46 +0000 TheDude ----------------

var renderer:PixelRenderer ;
var emitterCount:int=0;
var eArray:Array = new Array();


function Explode(ob:MovieClip, vx, vy)
{

//positions the Renderer around the object/emitter
var gb:Point = globalPosition(ob);
var rect1:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight );
rect1.offset(-scene.x, -scene.y);

renderer = new PixelRenderer(rect1);
//Add whatever filters you need for the renderer here.
var bb:BlurFilter = new BlurFilter( 2, 2, 1 );
renderer.addFilter(bb);
//scene displayobject for emitters
scene.addChild( renderer );

var emitter:Emitter2D = new Emitter2D();
eArray.push(emitter);

eArray[emitterCount].counter = new Blast( 300 );
eArray[emitterCount].addInitializer( new SharedImage( new Line( 2 ) ) );
eArray[emitterCount].addInitializer( new Lifetime( 0.2,1.2 ) );
eArray[emitterCount].addInitializer( new ColorInit( 0x00000000,0x00000000 ) );
eArray[emitterCount].addAction( new Age( Quadratic.easeIn) );
eArray[emitterCount].addAction(new ColorChange(0xFFFF3300, 0xFFFFFF00));
eArray[emitterCount].addAction( new Move() );
eArray[emitterCount].addInitializer( new Position( new DisplayObjectZone( ob, renderer )) );
eArray[emitterCount].addInitializer( new Velocity( new DiscZone( new Point( vx*10,vy*10 ), 200, 0)));
eArray[emitterCount].addAction( new RandomDrift( 15, 15 ) );
renderer.addEmitter(eArray[emitterCount] );
eArray[emitterCount].start( );

//GARBAGE DISPOSAL

eArray[emitterCount].addEventListener( EmitterEvent.EMITTER_EMPTY, kill_particles );
emitterCount++;

};

function kill_particles( ev:EmitterEvent ):void
{
ev.target.stop();
renderer.removeEmitter( Emitter2D( ev.target ) );
ev.target.removeEventListener( EmitterEvent.EMITTER_EMPTY, kill_particles );

ev = null;
scene.removeChild(renderer);
renderer = null;
}

The above works terrifically well until the Explode function is called more than once in a short duration of time- before the particles from the previous explosion are finished and the emitter has not triggered the EMITTER_EMPTY event.
I thought that storing the emitters in an array would work but nope, I get particle freeze and an error message.

Can anybody see anything obviously wrong with the code or offer a alternative solution? ]]>
Ah another error with emitters http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=487#Comment_487 http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=487#Comment_487 Mon, 10 Nov 2008 19:10:51 +0000 Richard Ah another error with emitters http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=488#Comment_488 http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=488#Comment_488 Tue, 11 Nov 2008 05:21:26 +0000 TheDude at bhunternew_fla::MainTimeline/kill_particles()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.flintparticles.common.emitters::Emitter/update()
at org.flintparticles.common.emitters::Emitter/updateEventListener()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.flintparticles.common.utils::FrameUpdater/frameUpdate() ]]>
Ah another error with emitters http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=489#Comment_489 http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=489#Comment_489 Tue, 11 Nov 2008 06:59:14 +0000 Richard Ah another error with emitters http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=490#Comment_490 http://flintparticles.org/forum/comments.php?DiscussionID=119&Focus=490#Comment_490 Wed, 12 Nov 2008 14:54:44 +0000 TheDude