To create an explosion in Flash like the one above we first need the frames that make up the animation. We will be using 25 .png files with transparent backgrounds and a resolution of 100x100 for this animation. To learn more check out Explosions in Studio Max.
The first thing we need to do is create a movie clip that will hold the explosion animation.
Click on File - Import - Import to Stage.
Select the first frame in the series of explosion frames.
You should see the following dialog box.
DO NOT click yes. We don't want all of the frames to load at this time. All we need is the first frame, from which we will create the movie clip object.
Press F8 to create a movie clip from this image. It would be best if the registration point were centered.

Double click the movie clip to edit it, and once again click
File - Import - Import to Stage.
Select the first frame in the explosion animation sequence and click OK. This time we want to load all of the images in the sequence so click yes when the dialog box appears.
The 25 frames should load in sequence creating the explosion animation. Next we need to add a stop() script to the first frame so that the animation doesn't play on a continuous loop. In the example above the very first frame of the animation was deleted. Doing this makes the movie clip invisible when it is stopped on the first frame. This allows us to leave it on the stage rather than hiding it off stage or setting it's _visible property to false every time we don't need it.
All that's left to do now is create a mouse listener function that will play the animation wherever the mouse is clicked.
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function(){
if(boom_mc._currentframe == 1){
boom_mc._x = _xmouse;
boom_mc._y = _ymouse;
boom_mc.play();
}
}
Mouse.addListener(mouseListener);
All the mouse listener function does is move the explosion movie clip to the mouse's current position and then play it. Remember that the first frame is blank so we can just leave the clip there when it finishes.
You might also be interested in





