Search Tutorials
Fire effect class (Fire)by WinxBefore Flash 8 we made fire mainly by drawing flames and animating every frame. We have use some programs like Photoshop or other that make animated gifs or into Flash itself. We have achived big .fla size, little reality cos of repeating frames and even low customization. Thx to Ken Perlin and his Perlin noise function, gives mankind opportunity programatically to create nature texture like wood, water, marible, fire, clouds ..... Perlin noise function is added to Flash 8 AS2 which allow us to make realistic textures and by using Flash animating engine make them alive. Making Fire programatically takes 4 planing steps: First step is to make gradient source movie clip that make fire color and form : //create gradient movie that form the fire color mcEx.createCustomGradientMovieClip(mcFire,"fireGradientSource",drawFunc,9,colors,alphas,ratios,"pad", "LinearRGB",0,new Point(0,0),null,width,height,90);//+15+10 Note: I have use function createCustomGradientMovieClip(..) from MovieEx class to create gradient Movie Clip but u can write your own.
Note: Use your own drawFunc to draw Fire form.
In second step we need to create flame granularity texture. So we apply perlinNoise on a bmp that
we have created before.
In second step we need to create flame granularity texture. So we apply perlinNoise on a bmp that we have created before. //create perlin noise flame granularity classObject.perlinNoiseBitmap.perlinNoise(classObject.sampleSize/ false,true,1,true,classObject.noiseOffsets); Then we need to create fire flames. For that we will use DisplacementMapFilter on a perlinNoiseBitmap and then apply on Fire gradient source movie clip. classObject.displacementMapBitmap.draw(classObject.mcPerlinNoiseBitmapContainer); //apply diplaced fire parts filter on gradient source (dying) classObject.mcFire.fireGradientSource.filters =[classObject.fltDM]; Finnaly we will animating fire (make flames moves) by changing PerlinNoise noiseOffsets in EnterFrame or Interval events.
//make flames moving
classObject.noiseOffsets[i].x = classObject.noiseOffsets[i].x + classObject.noiseOffsetDeltas[i].x; classObject.noiseOffsets[i].y = classObject.noiseOffsets[i].y + classObject.noiseOffsetDeltas[i].y; Fire class contains: import effects.Fire;
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|