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

Explosion or Broken Flash Effect with ActionScript

This Flash ActionScript Particle System tutorial series show how to create a broken or explode flash effect with ActionScript 3. Three different flash breaking or flash explosion effects were created. The first flash effect is simply breaking the Football object into number of smaller balls when touch the ground. While the other two flash effects will break or explode the Football into pieces against an object.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

This Flash explosion or broken effect is a rather simple flash actionscript particle system when compare with previous tutorials. The football object break or explode into number of smaller balls when fall on the ground.

The completed Flash Movie of this tutorial is shown as above.

Flash ActionScript Codes:

// Use ENTER_FRAME event to fire action for every frame.
stage.addEventListener(Event.ENTER_FRAME, dropBall);

 

function dropBall(evt:Event):void {

// Keep track the location of the ball:
// Height of Stage = 384
// Diameter of football = 40
// Point the football touch the bottom = 384 - 20 = 364

if (ball_mc.y < 364) {

ball_mc.y += 4;
} else {
ball_mc.visible = false;

// Explode the football when touch the bottom
stage.addEventListener(Event.ENTER_FRAME, flyingOut);


}

}



//Call the dropBall function when movie starts.
//Therefore the football will start moving when movie starts.
dropBall(null);

// Declare number of small balls to born when explode
var numOfBall:uint = 30;

// Create an Array to hold the balls
var ballArray:Array = new Array();

 

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

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

// Add the ball to the stage
addChild(ball);

// Assign start location of balls
// stage.stageWidth = 512
// stage.stageHeight = 384
ball.x = 256;
ball.y = 364;

// Assign random scale to balls
// Math.random returns value between 0 - 1
// i.e.
// Minimum value = 0.2 + 0 = 0.2
// Maximum value = 0.2 + 0.4 = 0.6
// Summary:
// Assign random scale between 0.2 and 0.6
ball.scaleX = 0.2 + Math.random() * 0.4;
ball.scaleY = ball.scaleX;

// We don't want to see the balls when newly added to the stage
ball.visible = false;

// 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
ball.yVelocity = Math.random() * 10 - 5;
ball.xVelocity = Math.random() * 10 - 5;

// Put ball into starArray Array to be used later for animation
ballArray.push(ball);

}


function flyingOut(evt:Event):void {

// Animate the balls one by one that hold in the Array
for (var i = 0; i < ballArray.length; i++) {
var ballParticles = ballArray[i];

// Set the balls visible again
ballParticles.visible = true;

// Balls moving out (flying out) from the center
ballParticles.y += ballParticles.yVelocity;
ballParticles.x += ballParticles.xVelocity;

// If the balls move out the stage

if ( (ballParticles.x > 550) || (ballParticles.x < -40) || (ballParticles.y > 420) || (ballParticles.y < -40) ) {
// Stop the balls
ballParticles.xVelocity = 0;
ballParticles.yVelocity = 0;
}
}

}

Download Flash Source File:

Flash Source File The source code can be download at the end of this tutorial series.

Remarks:

This Flash ActionScript tutorial shows how to create a broken or explosion flash effect of an object.