import Particle; // Define our vector (just a dynamic array with a specied type in AS3!) var particleVect:Vector. = new Vector.; // Define our number of particles to display on the screen and a start/stop animation flag var numberOfParticles:uint = 200; function addParticles():void { // Create however many particles we've entered into our numberOfParticles variable for (var loop:uint = 0; loop < numberOfParticles; loop++) { // Create a new instance of Particle and add it to our Vector of Particles particleVect.push(new Particle()); // Randomise the x (horizontal) and y (vertical) locations on stage particleVect[loop].x = Math.random() * stage.stageWidth; particleVect[loop].y = Math.random() * stage.stageHeight; // Randomise alpha particleVect[loop].alpha = Math.random(); // Randomise size between 0% and 100% (i.e. between 0.0 and 1.0) var sizeScale:Number = Math.random(); particleVect[loop].scaleX = sizeScale; particleVect[loop].scaleY = sizeScale; // Add the particle to the stage addChild(particleVect[loop]); } // End of for loop } // End of addParticles function // Kick off the animation and let it run forever addParticles();