«

»

Nov 04

Swishmax 4 Fireworks Tutorial Using Color Matrix Filter

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.

http://www.swish-designs.co.uk/blog/wp-content/plugins/downloads-manager/img/icons/ico_excel.gif 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"]

VN:F [1.9.22_1171]
Rating: 4.5/5 (10 votes cast)
VN:F [1.9.22_1171]
Rating: +6 (from 8 votes)
Swishmax 4 Fireworks Tutorial Using Color Matrix Filter, 4.5 out of 5 based on 10 ratings

24 comments

2 pings

Skip to comment form

  1. chapmart

    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

    VN:F [1.9.22_1171]
    Rating: 4.0/5 (2 votes cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  2. Craig Lowe

    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.

    VN:F [1.9.22_1171]
    Rating: 4.5/5 (2 votes cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  3. STRANGER710

    hi
    good Fireworks Tutorial
    thanks a lot

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  4. STRANGER710

    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.

    VN:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  5. STRANGER710

    then write in Replace with .. press SHIFT + the button has a red color in picture
    http://img105.herosh.com/2010/12/15/47179937.jpg

    VN:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  6. Craig Lowe

    thanks, glad you like the tutorial. inverted Quotation marks now fixed.
    i have no idea what caused them to invert.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  7. eherren57

    Craig, can you do this tutorial in Swishmax or will this only work in Swishmax 4?

    Thanks in advance

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: -2 (from 2 votes)
  8. Craig Lowe

    it could be done in swishmax the code would be slightly different

    onLoad () {
    }
    onEnterFrame() {
    }
    movieclip = sprite
    outcome is exactly the same.

    VN:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  9. Craig Lowe

    code fixed above no errors now. quotation marks was inverted when i copied and pasted
    see here ”false“ now corected.

    VN:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  10. dorime

    thank you good Fireworks perfect

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  11. Craig Lowe

    thanks, and you are welcome..

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  12. FalconWebMaster

    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?

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  13. Craig Lowe

    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.

    VN:F [1.9.22_1171]
    Rating: 3.0/5 (1 vote cast)
    VN:F [1.9.22_1171]
    Rating: -1 (from 1 vote)
  14. girreaver

    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.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  15. Craig Lowe

    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.

    VN:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  16. janmsel

    onSelfEvent (load) {
    for (i=0; i

    wat line shld be added after to this while copying it just comes only these lines..

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  17. Craig Lowe

    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.

    VN:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  18. nonoo

    Thank you very Much but im facing a problem , how can i paste the code ?! lol im new to this program :) !!

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  19. Craig Lowe

    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.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  20. conrad

    I bought the Tutorial, but i didn’t get the files?

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  21. Craig Lowe

    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.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  22. conrad

    Thanks Craig I got the files, and it works brilliantly!

    VN:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  23. Craig Lowe

    Your welcome, thanks for letting me know :)
    and thank you for your support.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  24. bobsoriginal

    GREAT WORK! THANKS. Code isn’t my strong point.

    VN:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  1. Swishmax 4 | swishit.com

    [...] Swish 4 Fire Works Tutorial [...]

Leave a Reply

6 visitors online now
2 guests, 4 bots, 0 members
Max visitors today: 11 at 03:33 am UTC
This month: 27 at 05-17-2013 01:24 pm UTC
This year: 39 at 01-01-2013 12:46 pm UTC
All time: 109 at 12-07-2012 11:00 pm UTC