Using again Perlin noise, we can have a very nice fire effect for our flash objects.

Online demo ( requires flash ).

The process can be explain just using two bitmaps in a loop proccess:

  • Draw our object over the fire bitmap
  • Generate perlin noise in the noise bitmap
  • Substract the noise in the fire
  • Move our fire up

The first and last step together, create and displace up a copy of our source:

The second step creates a noise patter:

And the third step, subtract both bitmaps

We only need to add another bitmap, and set a palette to give a better color to our fire.

The main loop in as3 is like this:

// draw source
_greyBmp.draw( _objToBurn );

// perlin noise
_coolingBmp.perlinNoise( 100 , 100, 2 , 100 , false, false, 0, true, _offset);
_offset[1].y += _fireVy;

// substract perlin noise
_greyBmp.draw(_coolingBmp, null, null, 'subtract' );

// move fire
_greyBmp.scroll( 0 , -3 );

// color fire
_fireBmp.paletteMap(_greyBmp, _greyBmp.rect, _zeroPoint , _palette );

Download: ActionScript Flames class