package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(backgroundColor="#000000", frameRate=30)]
public class ParticleTest extends Sprite {
private var _ballNum:uint=35;
private var _ballAr:Array=[];
public function ParticleTest() {
addEventListener(Event.ADDED_TO_STAGE,init);
}
private function init(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE,init);
addEventListener(Event.ENTER_FRAME,render)
}
private function render(e:Event):void{
if(_ballAr.length!=_ballNum){
_ballAr.push(new Particle(_ballAr.length-1));
_ballAr[_ballAr.length-1].addChild(this)
}
for(var i:uint=0;i<_ballAr.length;i++){
_ballAr[i].update()
}
}
}
}
import flash.display.Sprite;
import flash.display.DisplayObjectContainer;
import flash.filters.*
class Ball extends Sprite {
private var _id:uint
public function Ball(id:uint) {
_id=id
drawCirc();
}
private function drawCirc():void
{
var color:uint=0xFFFFFF*Math.random()
graphics.beginFill(color);
graphics.drawCircle(0,0,10);
graphics.endFill();
blendMode="add"
filters=[new GlowFilter(color,1,8,8)]
}
}
class Particle{
private var _x:Number;
private var _y:Number;
private var _z:Number;
private var _scaleX:Number;
private var _scaleY:Number;
private var _id:uint;
private var _graphic:Ball;
private var _rad:Number=1;
private var _r:Number=100;
public function Particle(num:uint){
_id=num;
_graphic=new Ball(_id);
_rad=Math.PI*_id/2
_y=480;
}
public function update():void
{
_y=_y-2
_r=(480-_y)/2
_rad=_rad+0.1;
_x=Math.cos(_rad)*_r+240;
_z=Math.sin(_rad)*_r+240;
_scaleX=_scaleY=_z/480*(480-_y)/480
_graphic.x=_x;
_graphic.y=_y;
_graphic.scaleX=_scaleX;
_graphic.scaleY=_scaleY;
if(_y<0){
init()
}
}
private function init():void
{
_y=480
}
public function addChild(container:Sprite):void
{
trace(container)
container.addChild(_graphic)
}
}