Free ActionScript

Flash AS2 & AS3 Tutorials, Game Code, Effects, Source Files & Sample Downloads

Dynamic Explosion Generator


Create explosion effects dynamically with AS3.

Example comes preloaded with a small, medium, and large explosion effects. Easily customizable for additional effects.


Download Fla Sample

Download Fla Sample

8 Responses


thanks for this nice example.

Some minor points:
-, timeHandler: Math.round(Math.random() * 2) does return 0, 1, or 2 with uneven chances; use floor instead
-, timeHandler: maybe it is easier to store the DisplayContainer for the different explos in an array and then just use a random num to acces an index in that array. No need for the inflexible if else if. Something like that may do:
private var _explos:Array = new Array();

_explos = [_smallExplosion,_mediumExplosion,_largeExplosion];

_explos[_randomNumber].create(_randomX, _randomY);
- why are there 3 different classes for 3 kinds of explosions though the code is identical? They are just instantiated with different values. Would it not be easier to have one explosion class instead and customize it using params?

    • Hi slarti5,

      Thanks for the tips! I’ll be sure to implement your suggestions and give you proper credit.

      The reason there are 3 different Classes (one for each explosion effect) is because I found it easier to customize the effects that way. Each effect has a lot of parameters, so it was easier for me to do it this way.

      There’s of course nothing wrong with having one abstract class and just passing it an object with parameters. It’s all about preference I suppose.


  • oh, and one more point I forgot to mention: use a bitmap for the burn marks instead of many movie clips. The mcs will slow down constantly the Flash player since they add up in numbers (createBurnMark in Draw the burn mark to one single bitmap so that you never need to add an mc to the display list

    • Could You give some example code how to do that kind of update for that code? I really would like to use that Dynamic Exploasion Generator, but if it is possible to make some improvements I would like to have them :)

    • That’s a good quick and easy improvement to the current script. I was actually reworking the whole script to use blitting all around (explosions and burn marks). Not sure when I’ll be done with it…

  • I have downloaded the library and tried to publish but I get errors because it cannot find the Light, BurnMark and fireball objects – what should I do?

  • Hi there and thanks for a great script.
    I like it a lot.
    I´m having one question, is it possible to make the external AS cod internal?
    How do i do that?
    Thank you.

  • Leave a Reply

    You must be logged in to post a comment.