particles

Vodpod videos no longer available.

more about "particles", posted with vodpod

AS3:

addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
for (var i:int = 0; i<10; i++){
var particle:MovieClip = new Circle();
particle.x = mouseX;
particle.y = mouseY;
setupParticle(particle);
}
}

function setupParticle(mc:MovieClip):void{
mc.velX = Math.random() * 10 – 5;
mc.velY = Math.random() * 10 – 5;
mc.scaleVel = Math.random() * 0.01 + 0.01;
mc.posX = mc.x;
mc.posY = mc.y;
addChild(mc);
mc.addEventListener(Event.ENTER_FRAME, onRunParticle);
}

function onRunParticle(evt:Event):void{
var mc:MovieClip = MovieClip(evt.currentTarget);
//mc.velY += 1;
mc.posX += mc.velX;
mc.posY += mc.velY;

mc.scaleX -= mc.scaleVel;
mc.scaleY = mc.scaleX;
mc.x = mc.posX;
mc.y = mc.posY;

// kills the particle
if (mc.scaleX stage.stageHeight){
if (mc.parent){
mc.parent.removeChild(mc);
mc.removeEventListener(Event.ENTER_FRAME, onRunParticle);
}
}
//}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s