Search tutorials
Step 2:actionscript
¡ö Choose Insert--> New Symbol.Make it a movie clip named firework.¡ö From the Library (Window--> Library) drag in an instance of myBeam. In the Property inspector, type myBeam1 in the Instance Name text box.
¡ö Insert a layer named actions. Add keyframes in Frames 2 and 3. In the first keyframe, type or paste in the following ActionScript.
Code
//This action script duplicates the
//symbol instance myBeam1
//and rotates it to appear as the
//firework. It randomizes the//overall size of the firework, as
//well as the individual beam
//lengths. It also randomizes the
//color of each firework.
//Initialize variables
i=0;
//Cf is the variable that counts the
//frame and aids in setting
//the alpha value so that the
//fireworks twinkle.
cf=0;
//Number of beams regulates the
//fullness of each firework.
numberOfBeams=40;
// Random sizes are set for a single
//firework on the screen
myScale = 20 + Random(80);
//Make the instance, myBeam1,
//visible. This is necessary because
//myBeam1 gets set to invisible
//below.
setProperty("myBeam1",_visible,true)
;
// A maximum random size is set for
//the next firework on the screen
xyscalevar = 20 + Random(80);
//Randomize the color of the next
//firework
colorArray=["FF","00","33","99","66",
"CC"]
myColor=new Color(myBeam1);
myColor.setRGB("0x"+colorArray
[Random(6)]+colorArray[Random(6)]+
colorArray[Random(6)]);
// The following lines create the
//firework from a single beam
// and give each beam a random length
//which does not exceed the maximum
//size
// set by the variable xyscalevar
//above
do {
duplicateMovieClip("myBeam1","beam"
add i,i);
setProperty("beam" + i,_rotation,
random(360));
setProperty("beam" +
i,_xscale,myScale+random(myScale));
setProperty("beam" +
i,_yscale,myScale+random(myScale));
i = Number(i) + 1;
)
while (Number(i)<=numberOfBeams
)
//Make the instance, myBeam1,
//invisible. This is necessary
//because myBeam1 was never resized
//for this particular
//firework and it would look odd if
//it were visible.
setProperty("myBeam1",_visible,false
);
| » Level Basic |
|
Added: 2003-12-26 Rating: 6 Votes: 61 |
| » Author |
| 18 years old,student,new to Flash |
| » Download |
| Download the files used in this tutorial. |
| Download (0 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!