Particles in AS3 using the TweenLite engine. Code is below, very easy to follow.
//import the tween classes
import gs.TweenLite;
import gs.easing.*
//create the container and particles
var particleCotainer:MovieClip = new MovieClip();
var particleArray:Array = new Array();
var particleArrayb:Array = new Array();
var maxParticles:Number = 200;
//add the particle container to the display
addChild(particleCotainer);
//create the function to add the particles
function addParticle(e:Event)
{
- var dot:Particle = new Particle();
var dotb:Particle = new Particle();
particleCotainer.x = stage.stageWidth/2;
particleCotainer.y = stage.stageHeight/2+120;
dot.scaleX = dot.scaleY = Math.random() * .8 + .2;
dotb.scaleX = dotb.scaleY = Math.random() * .6 + .1;
dotb.xMovement = Math.random() * -200;
dotb.yMovement = Math.random() * -200;
dot.xMovement = Math.random() * 200;
dot.yMovement = Math.random() * -200;
particleArray.push(dot);
particleArrayb.push(dotb);
particleCotainer.addChild(dot);
particleCotainer.addChild(dotb);
dot.cacheAsBitmap = true;
dotb.cacheAsBitmap = true;
//create the movement for each particle
TweenLite.to(dot, 2, {y:dot.yMovement, x:dot.xMovement, alpha:.5, rotation:90});
TweenLite.to(dotb, 2, {y:dotb.yMovement, x:dotb.xMovement, alpha:.5, rotation:-90});
TweenLite.to(dot, 8, {y:200, alpha:0, rotation:90, delay:1.5, overwrite:0, ease:Strong.easeIn});
TweenLite.to(dotb, 8, {y:200, alpha:0, rotation:-90, delay:1.5, overwrite:0, ease:Strong.easeIn});
}
//create the timer to call the function. Runs every 100 milliseconds
var myTimer:Timer = new Timer(100);
myTimer.addEventListener(TimerEvent.TIMER, addParticle);
myTimer.start();



























Hi Brusca,
That looks great and just what I’m looking for, but as I’m new to AS3, can’t work out how to add this into my flash file.
Do I just put that on frame 1 and have 2 seperate MovieClips in the library with linkage, or have them on the stage and identifiy them there?
Thanks in advance
Exactly. Place the script on frame 1 and link to the movie clip in the library called “Particle”.