Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

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
addChild(star);

// 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.