Thunder
/**
* Copyright heart_thai ( http://wonderfl.net/user/heart_thai )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/uJ4b
*/
package {
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.events.Event;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.utils.Timer;
[SWF(backgroundColor="#000000")]
public class FlashTest extends Sprite {
private var bmp:BitmapData;
private var canvas:Bitmap;
private var blur:BlurFilter;
private var makeTime:Timer;
private var delayTime:Timer;
private var drawX:Number;
private var drawY:Number;
public function FlashTest() {
blur = new BlurFilter(2,2,1);
bmp = new BitmapData(stage.stageWidth , stage.stageHeight ,false , 0x000000 );
canvas = new Bitmap(bmp);
addChild( canvas );
makeTime = new Timer( 3000 );
delayTime = new Timer( 20 , 1000 );
makeTime.addEventListener( TimerEvent.TIMER , makeThunder );
delayTime.addEventListener( TimerEvent.TIMER , loop );
this.addEventListener( Event.ENTER_FRAME , blurThunder );
makeTime.start();
makeThunder();
}
private function makeThunder( e:TimerEvent=null):void{
drawY = 0;
drawX = stage.stageWidth/2;
delayTime.start();
}
private function loop(e:TimerEvent):void{
for(var i:int=0; i<=100 ; i++){
bmp.setPixel( drawX , drawY , 0x00FFFF );
drawY += 0.5;
drawX += (Math.random()*10)-5;
}
}
private function blurThunder( e:Event ):void{
bmp.applyFilter( bmp , bmp.rect , new Point(),blur );
}
}
}