Particle
/**
* Copyright Caiim ( http://wonderfl.net/user/Caiim )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/AvUC
*/
package {
import flash.display.Graphics;
import flash.filters.GlowFilter;
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Sprite;
[SWF(backgroundColor="0x000000")]
public class FlashTest extends Sprite {
private var sw:int = stage.stageWidth;
private var sh:int = stage.stageHeight;
public function FlashTest() {
// write as3 code here..
addEventListener(Event.ENTER_FRAME,push);
}
private function push(e:Event)
{
if(numChildren<50)
{
var _mc:MovieClip = new MovieClip();
var g:Graphics = _mc.graphics;
g.beginFill(0x00aaaa);
g.drawCircle(1,1,3+Math.random()*10);
_mc.x = -50+Math.random()*sw;
_mc.y = sh+_mc.height+10;
_mc.speed = _mc.width/5+Math.random()*_mc.width/2;
var glow:GlowFilter = new GlowFilter(0x00aaaa, 1, _mc.width*2/3,_mc.width*2/3,3, 3);
_mc.filters = [glow];
_mc.addEventListener(Event.ENTER_FRAME, up);
addChild(_mc);
}
}
private function up(e:Event)
{
var _mc:MovieClip = MovieClip(e.target);
_mc.y-=_mc.speed;
_mc.x+=_mc.speed/5;
_mc.alpha = _mc.y/sh;
if(_mc.y < -_mc.height)
{
_mc.removeEventListener(Event.ENTER_FRAME, up);
removeChild(_mc);
}
}
}
}