Sparkler

This example uses the FollowMouse activity to make the emitter follow the mouse around. Roll over the black space above to move the sparkler.

package
{
  import org.flintparticles.twoD.emitters.Emitter2D;
  import org.flintparticles.twoD.renderers.BitmapRenderer;

  import flash.display.Sprite;
  import flash.filters.BlurFilter;
  import flash.filters.ColorMatrixFilter;
  import flash.geom.Rectangle;

  [SWF(width='400', height='400', frameRate='60', backgroundColor='#000000')]
  
  public class Main extends Sprite
  {
    private var emitter:Emitter2D;
    
    public function Main()
    {
      var renderer:BitmapRenderer = new BitmapRenderer( new Rectangle( 0, 0, 400, 400 ) );
      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 );
      
      emitter = new Sparkler( renderer );
      renderer.addEmitter( emitter );
      emitter.start( );
    }
  }
}
package
{
  import org.flintparticles.common.actions.Age;
  import org.flintparticles.common.counters.Steady;
  import org.flintparticles.common.displayObjects.Line;
  import org.flintparticles.common.initializers.ColorInit;
  import org.flintparticles.common.initializers.Lifetime;
  import org.flintparticles.common.initializers.SharedImage;
  import org.flintparticles.twoD.actions.Move;
  import org.flintparticles.twoD.actions.RotateToDirection;
  import org.flintparticles.twoD.activities.FollowMouse;
  import org.flintparticles.twoD.emitters.Emitter2D;
  import org.flintparticles.twoD.initializers.Velocity;
  import org.flintparticles.twoD.zones.DiscZone;

  import flash.display.DisplayObject;
  import flash.geom.Point;

  public class Sparkler extends Emitter2D
  {
    public function Sparkler( renderer:DisplayObject )
    {
      counter = new Steady( 150 );
      
      addInitializer( new SharedImage( new Line( 8 ) ) );
      addInitializer( new ColorInit( 0xFFFFCC00, 0xFFFFCC00 ) );
      addInitializer( new Velocity( new DiscZone( new Point( 0, 0 ), 350, 200 ) ) );
      addInitializer( new Lifetime( 0.2, 0.4 ) );
      
      addAction( new Age() );
      addAction( new Move() );
      addAction( new RotateToDirection() );
      
      addActivity( new FollowMouse( renderer ) );
    }
  }
}
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.Line;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.activities.FollowMouse;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;    

var emitter:Emitter2D = new Emitter2D();
emitter.counter = new Steady( 150 );

emitter.addInitializer( new SharedImage( new Line( 8 ) ) );
emitter.addInitializer( new ColorInit( 0xFFFFCC00, 0xFFFFCC00 ) );
emitter.addInitializer( new Velocity( new DiscZone( new Point( 0, 0 ), 350, 200 ) ) );
emitter.addInitializer( new Lifetime( 0.2, 0.4 ) );

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

var renderer:BitmapRenderer = new BitmapRenderer( new Rectangle( 0, 0, 400, 400 ) );
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 ] ) );
renderer.addEmitter( emitter );
addChild( renderer );

emitter.addActivity( new FollowMouse( renderer ) );

emitter.start( );
<?xml version="1.0" encoding="utf-8"?>
<s:Application
  xmlns:fx="http://ns.adobe.com/mxml/2009" 
  xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:f="http://flintparticles.org/2009/flint2d"
  xmlns:filters="flash.filters.*"
  width="400" height="400"
  backgroundColor="#000000">
  
<f:BitmapRenderer id="renderer" width="400" height="400">
  <f:preFilters>
    <filters:BlurFilter blurX="2" blurY="2" quality="1"/>
    <filters:ColorMatrixFilter matrix="{[ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.95,0 ]}"/>
  </f:preFilters>
  <f:emitters>
    <f:Emitter id="emitter" autoStart="true">
      <f:counter>
        <f:Steady rate="150"/>
      </f:counter>
      <f:initializers>
        <f:Velocity>
          <f:DiscZone centerX="0" centerY="0" innerRadius="200" outerRadius="350"/>
        </f:Velocity>
        <f:SharedImage>
          <f:Line length="8"/>
        </f:SharedImage>
        <f:ColorInit minColor="0xFFFFCC00" maxColor="0xFFFFCC00"/>
        <f:Lifetime minLifetime="0.2" maxLifetime="0.4"/>
      </f:initializers>
      <f:actions>
        <f:Move/>
        <f:Age/>
        <f:RotateToDirection/>
      </f:actions>
      <f:activities>
        <f:FollowMouse renderer="{renderer}"/>
      </f:activities>
    </f:Emitter>
  </f:emitters>
</f:BitmapRenderer>
</s:Application>