# Flying Out Particle System Flash ActionScript Tutorial

Step 1: Create Random Particles on the Stage

To create Flash Particle System, the first step is to create all particles (stars) on the stage in random.

Please update flash player to view this Flash ActionScript tutorial!

## Flash Tutorial Content:

Like other Flash ActionScript Particle System, the first step is create all star particle on the stage. Position the star particle randomly on the stage of Flash Movie.

The Flash Movie of this Flash ActionScript Particle System tutorial is shown as above.

## Flash ActionScript Codes:

// Declare number of Star
var numOfStar:uint = 30;

// Creates 30 Stars on the stage.
for (var i:uint = 0; i < numOfStar; i++) {

// Create a new Star
// Remember to set linkage in Movie Library
var star:Star = new Star();

// Add the Star to the stage

// Assign start location of Star
// stage.stageWidth = 512
// stage.stageHeight = 384
// Math.random returns value between 0 - 1
star.x = Math.random() * 512;
star.y = Math.random() * 384;

// Assign random alpha to Stars if you like
// Math.random returns value between 0 - 1
// i.e.
// Minimum value = 0.4 + 0 = 0.4
// Maximum value = 0.4 + 0.6 = 1.0
// Summary:
// Assign random alpha between 0.4 and 1.0
//star.alpha = 0.4 + Math.random() * 0.6;

// Assign random velocity (y-axis) to the Ball
// Math.random returns value between 0 - 1
// i.e.
// Minimum value = 0 - 5 = -5
// Maximum value = 10 - 5 = +5
// Summary:
// Math.random returns value between -5 to 5
star.yVelocity = Math.random() * 10 - 5;
star.xVelocity = Math.random() * 10 - 5;

// We don't want Stars moving too slowly on the satge
// Adjust the speed in this case
if ( (star.yVelocity > -0.5) && (star.yVelocity < 0.5) ) {

star.yVelocity = 1.0;
}
if ( (star.xVelocity > -0.5) && (star.xVelocity < 0.5) ) {
star.xVelocity = 1.2;}
}

Remarks:

This Flash ActionScript Fly Out Particle System tutorial shows how to create particles randomly on stage of flash movie.