/**
* Copyright mautop ( http://wonderfl.net/user/mautop )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/oAS4
*/
// Mauricio Struckel
// Fire Experiment
package {
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.geom.Point;
import flash.geom.Matrix;
import flash.display.*;
[SWF(width = "800", height = "600", frameRate="30", backgroundColor="#000000")]
public class Fire extends Sprite {
private var bitMapCanvas:Bitmap;
private var bd:BitmapData;
private var canvasSpt:Sprite = new Sprite();
//constructor
public function Fire () {
drawLine ();
}
//method that returns the color array for the radial gradient fill
private function colorArray ():Array {
var fireColor:Array = [0xF7E233,0xE8500F, 0x2C018F];
return fireColor;
}
// draws a line into a sprite object and print it as a bitmap
private function drawLine () {
bd = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x00000000);
canvasSpt.x = stage.stageWidth/2;
canvasSpt.y = stage.stageHeight-3;
canvasSpt.graphics.lineStyle(1 , 0xFFFFFF, 1, false, LineScaleMode.HORIZONTAL,
CapsStyle.NONE, JointStyle.ROUND, 10);
canvasSpt.graphics.lineGradientStyle ( GradientType.RADIAL, colorArray (), [80,65,30], [0,200,255], null, SpreadMethod.PAD, InterpolationMethod.LINEAR_RGB,0);
canvasSpt.graphics.moveTo(-stage.stageWidth/4, 0);
canvasSpt.graphics.lineTo(stage.stageWidth/4, 0);
bd.draw(canvasSpt, new Matrix( 1, 0, 0, 1, stage.stageWidth/2, stage.stageHeight-3) , null, flash.display.BlendMode.LIGHTEN , null, true);
bitMapCanvas = new Bitmap(bd);
this.addChild(bitMapCanvas);
this.addEventListener(Event.ENTER_FRAME, fireLoop);
}
//
public function fireLoop(event:Event):void {
bd.scroll(0, - 2);
canvasSpt.graphics.lineGradientStyle ( GradientType.RADIAL, colorArray (), [30,65,30], [Math.random()*1,Math.random()*255,Math.random()*255], null, SpreadMethod.PAD, "rgb",0);
bd.draw(canvasSpt, new Matrix( Math.random(), 0, 0, 1, stage.stageWidth/2 , stage.stageHeight-3) , null, flash.display.BlendMode.LIGHTEN , null, true);
bd.applyFilter(bd, bd.rect, new Point(0, 0), new BlurFilter(10, 5));
}
}
}