Fire and Smoke

Flash required: You need version 9 or later of the free Flash player from Adobe to use this content. To download and install the free player from Adobe’s web site click here.

Source code

This project uses two emitters, one to create the fire and the other to create the smoke. The smoke is created from a number of circular particles at very low alpha which overlap to create the random smoke distribution. The fire is created from elliptical particles that are orientated so their pointy end points in the direction they're travelling.

var smoke:Emitter2D = new Emitter2D();
smoke.counter = new Steady( 10 );
  
smoke.addInitializer( new Lifetime( 11, 12 ) );
smoke.addInitializer( new Velocity( new DiscSectorZone( new Point( 0, 0 ), 40, 30, -4 * Math.PI / 7, -3 * Math.PI / 7 ) ) );
smoke.addInitializer( new SharedImage( new RadialDot( 6 ) ) );
  
smoke.addAction( new Age( ) );
smoke.addAction( new Move( ) );
smoke.addAction( new LinearDrag( 0.01 ) );
smoke.addAction( new ScaleImage( 1, 15 ) );
smoke.addAction( new Fade( 0.15, 0 ) );
smoke.addAction( new RandomDrift( 15, 15 ) );

smoke.x = 150;
smoke.y = 380;
smoke.start( );

var fire:Emitter2D = new Emitter2D();
fire.counter = new Steady( 60 );

fire.addInitializer( new Lifetime( 2, 3 ) );
fire.addInitializer( new Velocity( new DiscSectorZone( new Point( 0, 0 ), 20, 10, -Math.PI, 0 ) ) );
fire.addInitializer( new Position( new DiscZone( new Point( 0, 0 ), 3 ) ) );
fire.addInitializer( new SharedImage( new FireBlob() ) );

fire.addAction( new Age( ) );
fire.addAction( new Move( ) );
fire.addAction( new LinearDrag( 1 ) );
fire.addAction( new Accelerate( 0, -40 ) );
fire.addAction( new ColorChange( 0xFFFFCC00, 0x00CC0000 ) );
fire.addAction( new ScaleImage( 1, 1.5 ) );
fire.addAction( new RotateToDirection() );

fire.x = 150;
fire.y = 380;
fire.start( );

var renderer:BitmapRenderer = new BitmapRenderer( new Rectangle( 0, 0, 300, 400 ) );
renderer.addEmitter( fire );
renderer.addEmitter( smoke );
addChild( renderer );

This effect can be created in 2D or 3D. the full set of examples contains source code for creating 2D and 3D versions using frame scripts and using classes, plus 3D versions for Away3D and Papervision3D.