Example:
First Of All
Open SwishMax 4 set your movie properties to
Black Background.
width = 500
Height = 450
Frame Rate = 35.

here is an animated gif of a firework which we will be using in ths tutorial.
save this to your project folder, right click | save as.
once you have saved the firework gif to your hard drive we need to import it to the stage of our swishmax 4 movie.
click File | Import to stage| Animation, select gif and import.
once imported you will see a new movieclip has apeared firework_gif rename this to firework.

you will need to add 15 frames infront of the original frame 1
right click on the firework timeline and insert frame(s)

if some are struggling to understand this, or how to do it, download the sample file below.
|
|
download: Sample1 swishmax 4 firework tutorial (363.07KB) added: 04/11/2010 clicks: 1401 description: only download this file if you are struggling to add the 15 new frames in front of the original frame 1. this file only containes the added 15 frames and the imported firewok gif. |
now add the following code to the firework movieclip.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | onSelfEvent (enterFrame) { ran=random(70); scaleit=randomRange(50,150); if (ran=="7" && playing=="false") { this.play(); this._x=randomRange(70,400); this._y=randomRange(70,350); this._yscale=scaleit; this._xscale=_yscale; } } onSelfEvent (load) { playing="false"; } onFrame (16) { playing="false"; } onFrame (16) { stop(); } onFrame (17) { setLabel("play"); playing="true"; } onFrame (126) { gotoAndPlay(1); } onFrame (127) { stop(); } onFrame (2) { ranc=random(4); } onFrame (7) { if (ranc==0) { _parent.control.gotoAndPlay("blue"); } else if (ranc==1) { _parent.control.gotoAndPlay("pink"); } else if (ranc==2) { _parent.control.gotoAndPlay("green"); } else if (ranc==3) { _parent.control.gotoAndPlay("yellow"); } } |
it should now play like the movie shown below when you press Ctrl+T (test in player)
Ok. so now we need to create a new empty movieclip and name it control.

now add the following code to it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | onFrame (1) { stop(); } onFrame (2) { setLabel("blue"); } onFrame (3) { myFilter = new flash.filters.ColorMatrixFilter (); myFilter.matrix = new Array (0,0,0,0,0, 0,1,0,0,0, 0,0,2,0,0, 0,0,0,1,0); // | red | green | blue | alpha _parent.firework.filters = [myFilter]; } onFrame (4) { stop(); } onFrame (5) { setLabel("pink"); } onFrame (6) { myFilter = new flash.filters.ColorMatrixFilter (); myFilter.matrix = new Array (2,0,0,0,0, 0,1,0,0,0, 0,0,2,0,0, 0,0,0,1,0); // | red | green | blue | alpha _parent.firework.filters = [myFilter]; } onFrame (7) { stop(); } onFrame (8) { setLabel("green"); } onFrame (9) { myFilter = new flash.filters.ColorMatrixFilter (); myFilter.matrix = new Array (0,0,0,0,0, 0,1,0,0,0, 0,0,0,0,0, 0,0,0,1,0); // | red | green | blue | alpha _parent.firework.filters = [myFilter]; } onFrame (10) { stop(); } onFrame (11) { setLabel("yellow"); } onFrame (12) { myFilter = new flash.filters.ColorMatrixFilter (); myFilter.matrix = new Array (0,0,0,5,1, 2,0,0,0,1, 0,0,1,0,1, 0,0,0,1,0); // | red | green | blue | alpha _parent.firework.filters = [myFilter]; } onFrame (13) { stop(); } |
when you have done that, group the firework movie clip and the control movieclip together as a new movieclip ad name it firework.
now add the following code to Scene_1
1 2 3 4 5 6 7 | onSelfEvent (load) { for (i=0; i<3; i++) { for (j=0; j<5; j++) { duplicateMovieClip( "_root.firework", "firework"+(i+50*j), i+50*j ); } } } |
thats it press Ctrl+T (test in player) you should have a working display something like below.
you can add more colours by playing with the matrix colour filter settings.
Buy the final tutorial file £2.50 swishmax 4 swi file
[paiddownloads id="60"]






24 comments
2 pings
Skip to comment form ↓
chapmart
November 30, 2010 at 7:03 pm (UTC 1) Link to this comment
I am getting an error with a line of code in the fireworks example, running swishmax 4. I used your initial file just to make sure that it was not an issue with regard to adding the frames. Upon cutting and pasting the code for the first part, the code
if (ran==”7” && playing==”false“) {
is highlighted in yellow and will not run
if you have a moment, could you send me a note as to what i may have done incorrectly please?? thanks
chapmart2002@yahoo.com
Craig Lowe
December 2, 2010 at 10:21 am (UTC 1) Link to this comment
a common mistake when copying and pasting is not to have captured the whole code. example
nSelfEvent (enterFrame) {
ran=random(70);
scaleit=randomRange(50,150);
if (ran==”7″ && playing==”false”) {
instead of
onSelfEvent (enterFrame) {
ran=random(70);
scaleit=randomRange(50,150);
if (ran==”7″ && playing==”false”) {
Note the “o” is missing from the first line onSelfEvent simple mistake but will throw up an error and easy to miss when looking back through the scripting to find the error.
check that, i have also replied to your email.
STRANGER710
December 15, 2010 at 3:50 pm (UTC 1) Link to this comment
hi
good Fireworks Tutorial
thanks a lot
STRANGER710
December 15, 2010 at 5:30 pm (UTC 1) Link to this comment
hi again
i’m non native speaker but i can explain good
excause me Craig Lowe
chapmart…. the errer is in this mark ( ” ” ) i don’t know what’s called.. so go to Edit menu
then chose Replace … write in Find what this ( ” ) then write in Replace with this ( ” )
and you chose in right side Replace All button and ok.
do it with all new copy script.
STRANGER710
December 15, 2010 at 5:45 pm (UTC 1) Link to this comment
then write in Replace with .. press SHIFT + the button has a red color in picture
http://img105.herosh.com/2010/12/15/47179937.jpg
Craig Lowe
December 15, 2010 at 8:25 pm (UTC 1) Link to this comment
thanks, glad you like the tutorial. inverted Quotation marks now fixed.
i have no idea what caused them to invert.
eherren57
January 12, 2011 at 3:30 am (UTC 1) Link to this comment
Craig, can you do this tutorial in Swishmax or will this only work in Swishmax 4?
Thanks in advance
Craig Lowe
January 12, 2011 at 8:35 am (UTC 1) Link to this comment
it could be done in swishmax the code would be slightly different
onLoad () {
}
onEnterFrame() {
}
movieclip = sprite
outcome is exactly the same.
Craig Lowe
January 12, 2011 at 8:40 am (UTC 1) Link to this comment
code fixed above no errors now. quotation marks was inverted when i copied and pasted
see here ”false“ now corected.
dorime
January 18, 2011 at 2:34 am (UTC 1) Link to this comment
thank you good Fireworks perfect
Craig Lowe
January 18, 2011 at 8:19 am (UTC 1) Link to this comment
thanks, and you are welcome..
FalconWebMaster
June 28, 2011 at 6:20 pm (UTC 1) Link to this comment
Excellent Fireworks!
I’m having a little trouble getting this to work right. I’m not getting any errors, but the firework will ignite, pause, relocate and rescale, then continue. It’ll sometimes do that twice during one explosion. Do you know why this would be happening?
Does your final tutorial have the entire working solution?
Craig Lowe
June 28, 2011 at 10:29 pm (UTC 1) Link to this comment
yes
did you read and aply the following
you will need to add 15 frames infront of the original frame 1
right click on the firework timeline and insert frame(s)
if you strugle understanding or doing this then download the file provided it is done for you on that, then simply add the code and follow on.yes the final file has what is shown in the swf.
girreaver
August 21, 2011 at 12:20 am (UTC 1) Link to this comment
Hi, Excellent tutorial
Just one question, i downloaded the file provided with the 15 frames, but i keep getting the same behaviour as FalconWebMaster, do you have any idea of why this is happening, Thank you very much.
Craig Lowe
August 21, 2011 at 6:25 am (UTC 1) Link to this comment
hmm, i have now slightly amended the code for the firework movie clip copy and replace the existing code you have on the firework movieclip see if that solves your problem.. but i have gone through the tutorial myself and get no problems, so please check your script. failing that send me your swi file i will take a look through it for you.
janmsel
September 28, 2011 at 6:47 am (UTC 1) Link to this comment
onSelfEvent (load) {
for (i=0; i
wat line shld be added after to this while copying it just comes only these lines..
Craig Lowe
September 28, 2011 at 7:45 am (UTC 1) Link to this comment
Hello the full code you are looking for on Scene_1 is as follows.
onSelfEvent (load) {for (i=0; i<3; i++) {
for (j=0; j<5; j++) {
duplicateMovieClip( "_root.firework", "firework"+(i+50*j), i+50*j );
}
}
}
many thanks.
nonoo
May 5, 2012 at 3:33 pm (UTC 1) Link to this comment
Thank you very Much but im facing a problem , how can i paste the code ?! lol im new to this program
!!
Craig Lowe
May 6, 2012 at 11:50 am (UTC 1) Link to this comment
left click on the code show here drag whilst holding left mouse button until code block is highlighted, right click on the blue highlighted code and click copy.
in swishmax click on the script tab, right mouse click on line 1 and click paste.
your code block will be pasted, any line of code highlighted in yellow has an error.
if no line of code/s are highlighted the script is good to go.
conrad
June 1, 2012 at 2:34 pm (UTC 1) Link to this comment
I bought the Tutorial, but i didn’t get the files?
Craig Lowe
June 1, 2012 at 10:54 pm (UTC 1) Link to this comment
the download links was sent to your registered paypal email address. if this is not a valid or an unused email address you would have to supply me with a valid or used email address to send you the download link to, many thanks.
conrad
June 2, 2012 at 4:36 pm (UTC 1) Link to this comment
Thanks Craig I got the files, and it works brilliantly!
Craig Lowe
June 2, 2012 at 9:28 pm (UTC 1) Link to this comment
Your welcome, thanks for letting me know
and thank you for your support.
bobsoriginal
May 16, 2013 at 7:47 pm (UTC 1) Link to this comment
GREAT WORK! THANKS. Code isn’t my strong point.
Swishmax 4 | swishit.com
November 25, 2010 at 8:51 pm (UTC 1) Link to this comment
[...] Swish 4 Fire Works Tutorial [...]
SWiSHzone.com Official Blog » Blog Archive » Tutorial: Fireworks using the Color Matrix Filter
December 22, 2010 at 12:12 am (UTC 1) Link to this comment
[...] Check it out here. [...]