Flint Particle System Forum - Prevent Flint from "claiming" stage after removal. 2011-12-12T02:15:53+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Prevent Flint from "claiming" stage after removal. http://flintparticles.org/forum/comments.php?DiscussionID=433&Focus=1473#Comment_1473 2010-12-14T18:06:13+00:00 2011-12-12T02:15:53+00:00 ven http://flintparticles.org/forum/account.php?u=447 Hi, I'm working on a puzzle game, where each of the tiles is a movieclip. When matching tiles get removed an explosion (via Flint) is created. The problem I am having is that after the first ... I'm working on a puzzle game, where each of the tiles is a movieclip. When matching tiles get removed an explosion (via Flint) is created. The problem I am having is that after the first explosion, all mouse events are going to Flint even though I have deleted the explosion object. Can someone offer some help/suggestions.


Here is how init the explosion object.
explosions = new Flint( stage.width, stage.height );
addChild( explosions );

Later on when i need to create the explosions, I do:
explosions.addEmitter( x, y, c, c );

When I am done with the explosions I call the following routine:
explosions.removeEmitter();
removeChild( explosions );
explosions = null;

Here is the my Flint class ( I modified one of the examples from the website).

package
{
import flash.display.Sprite;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;

import flash.events.*;


import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.twoD.particles.*;

public class Flint extends Sprite
{
var emitters:Array;
var renderer:BitmapRenderer;

public function Flint( x:int, y:int )
{
emitters = new Array();

renderer = new BitmapRenderer( new Rectangle( 0, 0, x, y ) );
renderer.addFilter( new BlurFilter( 2, 2, 1 ) );
renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.95,0 ] ) );
addChild( renderer );

}


function addEmitter( x:int, y:int, colorMin:int, colorMax:int )
{
var emitter:Emitter2D = new Emitter2D();
emitter.counter = new Blast( 50 ); // steady, blast

emitter.addInitializer( new SharedImage( new Line( 1 ) ) );
emitter.addInitializer( new ColorInit( colorMin, colorMax ) );
emitter.addInitializer( new Velocity( new DiscZone( new Point( 0, 0 ), 100, 100 ) ) );
emitter.addInitializer( new Lifetime( 0.2, 0.4 ) );

emitter.addAction( new Age() );
emitter.addAction( new Move() );
emitter.addAction( new RotateToDirection() );

emitter.x = x;
emitter.y = y;

emitters.push ( emitter );
renderer.addEmitter( emitter );

emitter.start()
}

function removeEmitter()
{
//http://flintparticles.org/forum/comments.php?DiscussionID=203&page=1#Item_0

for ( var i:int = 0; i < emitters.length; i++ )
{
// Stop the emitter
emitters[i].stop();
// Clear all the cached particles
ParticleCreator2D( emitters[i].particleFactory ).clearAllParticles();
// Remove references to the emitter
renderer.removeEmitter( emitters[i]);
emitters[i] = null;
}

// Remove references to the renderer
removeChild( renderer );
renderer = null;
}

}
}]]>
Prevent Flint from "claiming" stage after removal. http://flintparticles.org/forum/comments.php?DiscussionID=433&Focus=1474#Comment_1474 2010-12-14T18:41:43+00:00 2011-12-12T02:15:53+00:00 ven http://flintparticles.org/forum/account.php?u=447 Never mind, I found the problem. It seems that I was creating multiple instances of explosions, hence I was only removing once instance of explosion instead of the many that I was unknowingly ... -ven]]>