forked from: Typhoon
// forked from mononoahare's Typhoon
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.filters.GlowFilter;
import flash.geom.Matrix;
import flash.geom.Point;
[SWF(frameRate=30, width=500, height=500, backgroundColor=0x000000)]
public class Main extends Sprite
{
public static const BUGS_LENGTH:int = 235;
private var _bugs:Array;
private var _filter:BitmapFilter;
private var _canvas:Sprite;
private var _film:BitmapData;
public function Main()
{
addEventListener(Event.ADDED_TO_STAGE, initialize);
}
private function initialize(e:Event):void
{
removeEventListener(e.type, arguments.callee);
_bugs = [];
_filter = new BlurFilter(8, 8, BitmapFilterQuality.LOW);
_canvas = new Sprite();
addChild(_canvas);
_film = new BitmapData(500, 500, true, 0);
addChild(new Bitmap(_film));
addEventListener(Event.ENTER_FRAME,render)
}
private function render(e:Event):void
{
var i:int,
p:Particle,
f:BitmapFilter,
g:Graphics = _canvas.graphics;
i = _bugs.length;
if (i < BUGS_LENGTH)
{
p = new Particle(i);
_bugs.push(p);
}
g.clear();
for each (p in _bugs)
{
p.update(g);
}
_film.lock();
_film.fillRect(_film.rect, 0);
_film.draw(_canvas, null, null);
_film.applyFilter(_film, _film.rect, new Point(), _filter);
_film.unlock();
}
}
}
import flash.display.Graphics;
class Particle
{
private var _id:int;
private var _x:Number;
private var _y:Number;
private var _z:Number;
private var _scaleX:Number;
private var _scaleY:Number;
private var _rad:Number=1;
private var _r:Number=100;
private var _color:uint;
public function Particle(id:int)
{
_id = id;
_rad = Math.PI * id / 2;
_y = 480;
_color = 0xFFFFFF * Math.random();
}
public function update(g:Graphics):void
{
_y -= 2;
_r = (480 - _y) / 2;
_rad += 0.1;
_x = Math.cos(_rad) * _r + 240;
_z = Math.sin(_rad) * _r + 240;
_scaleX = _scaleY = _z / 480 * (480 - _y) / 480;
g.beginFill(_color);
g.drawCircle(_x, _y, 10 * _scaleX);
g.endFill();
if (_y < 0) _y = 480;
}
}