Particle2
...
@author DefaultUser (Tools -> Custom Arguments...)
// write as3 code here..
package
{
import flash.display.MovieClip;
import flash.events.*;
/**
* ...
* @author DefaultUser (Tools -> Custom Arguments...)
*/
public class Particle extends MovieClip {
public function Particle() {
stage.frameRate = 40;
var ww:Wall = new Wall(stage.stageWidth,stage.stageHeight);
addChildAt(ww,0);
addEventListener(Event.ENTER_FRAME, func1);
}
public function func1(event:Event):void {
var p:ParticleMake = new ParticleMake(mouseX, mouseY, Math.random() * 13 - 7, Math.random() * -10, Math.random()*0.5 + 0.3, Math.random() * 0xffffff);
addChildAt(p,1);
}
}
}
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
class ParticleMake extends Sprite {
var posx:Number;
var posy:Number;
var velx:Number;
var vely:Number;
var grav:Number;
var col:uint;
var fill:BlurFilter;
var fillNum; int;
public function ParticleMake (num1:Number, num2:Number, num3:Number, num4:Number, num5:Number, num6:uint) {
posx = num1;
posy = num2;
velx = num3;
vely = num4;
grav = num5;
col = num6;
fillNum = 2;
fill = new BlurFilter(fillNum, fillNum);
var ball:Ball = new Ball();
addChild(ball);
x = posx;
y = posy;
filters = [fill]
scaleX = scaleY = Math.random() * 1.6 + 0.2;
var colo:ColorTransform = ball.transform.colorTransform;
colo.color = num6;
ball.transform.colorTransform = colo;
addEventListener(Event.ENTER_FRAME, func2);
}
public function func2(event:Event):void {
vely += grav;
posx += velx;
posy += vely;
fillNum += 0.2;
x = posx;
y = posy;
fill = new BlurFilter(fillNum, fillNum);
filters = [fill]
if (x < 0 || x > stage.stageWidth || y > stage.stageHeight) {
removeEventListener(Event.ENTER_FRAME, func2);
parent.removeChild(this);
}
}
}
class Ball extends Sprite {
public function Ball() {
var b:Sprite = new Sprite();
var randA:int = Math.random() * 6;
if(randA == 0) {
b.graphics.beginFill(0xffffff);
b.graphics.drawCircle(0, 0, 10);
addChild(b);
}else if (randA == 1) {
b.graphics.lineStyle(3, 0xffffff);
b.graphics.drawCircle(0, 0, 10);
addChild(b);
}else if (randA == 2) {
b.graphics.beginFill(0xffffff);
b.graphics.drawRect(0, 0, 10, 10);
addChild(b);
}else if (randA == 3) {
b.graphics.lineStyle(3, 0xffffff);
b.graphics.drawRect(0, 0, 10, 10);
addChild(b);
}else if (randA == 4) {
b.graphics.beginFill(0xffffff);
b.graphics.moveTo(0, -10);
b.graphics.lineTo( -5, 0);
b.graphics.lineTo(5, 0);
addChild(b);
}else if (randA == 5) {
b.graphics.lineStyle(3,0xffffff);
b.graphics.moveTo(0, -10);
b.graphics.lineTo( -5, 0);
b.graphics.lineTo(5, 0);
b.graphics.lineTo( 0, -10);
addChild(b);
}
}
}
class Wall extends Sprite {
public function Wall(a:Number,b:Number) {
var w:Sprite = new Sprite();
w.graphics.beginFill(0x000000);
w.graphics.drawRect(0, 0, a, b);
addChild(w);
}
}