Top 3 Products & Services
Dated: Aug. 12, 2004
Written By Cathy Jenkins (web designer) on: March 10, 2004
Creating a duplicate movie clip in flash is not the most useful thing you'll encounter. However, it is a good skill to have as it incorporates creating a tween, and writing your own actionscript. It is assumed that you already know how to create tweens and have some knowledge about action scripting in flash. Techiwarehouse already has some great tutorials which cover these basic skills.
Download the FLA Source Code as it contains all of the elements used in the movie, and will make this tutorial easier to understand. You can use the movie explorer in flash to see what symbols, graphics, and actions are used frame-by-frame. You can learn much more by looking at the FLA source code and reading this tutorial than following screenshots.
- Create a movie apart from the main stage of a graphic tweened off the stage.
- Create an instance of the movie mentioned above. This will be placed in the stage by you.
- Specify a name for the instance eg "myflake".
- Open up the library in flash and choose a button. Drag it anywhere on the stage. The actionscript for this button is below. Please proceed with the rest of the tutorial "action scripting time" before creating any actions for the buttons.
Action Scripting Time
- Specify the function name for your action. "billy" is used in my example.
- Declare the original instance eg "myflake" to be stationary.
- Create a loop and specify how many times to execute it in that code block. I chose 25.
- Replicate the original movie ie "myflake"
- Call each instance of the movie "myflake" and the iteration of the loop. Eg. "myflake1", "myflake2, "myflake3".
- Change the x, and y coordinates for each instance by evaluating the object using the evaluate function called "eval" and randomise the X and Y coordinates to 550, and 400 respectively. Or pick your own numbers to randomise by.
- Scale the X and Y coordinates. Use the variable called "myscale" (contains a random number between 1 and 100, or was it 0 to 99? Anyway that doesn't matter)
- Scaling by proportion requires us to scale both X and Y.
- Change the opacity with "myscale" to create the effect of distance.
- End the code.
- Put a stop after the first frame in your movie so it does not iterate.
- Earlier on you were told to create a button or to import 1 from the libary. Write some action script to call the billy function above when released. For example:
Frame 1 Action Scripting
sn1._visible = false;
sn2._visible = false;
sn3._visible = false;
flaketype = random(3);
duplicateMovieClip( eval("sn"+int(flaketype + 1)),"myflake"+x, x);
eval("myflake"+x)._x = random(550);
eval("myflake"+x)._y = random(400);
myscale = random(100);
eval("myflake"+x)._xscale = myscale;
eval("myflake"+x)._yscale = myscale;
eval("myflake"+x)._alpha = myscale;
eval("myflake"+x)._rotate = myscale;
myColor = Math.round( Math.random()*0xFFFFFF );
myColoredObject = new Color ("myflake"+x);
Button Action Scripting
Now that you've gotten free know-how on this topic, try to grow your skills even faster with online video training. Then finally, put these skills to the test and make a name for yourself by offering these skills to others by becoming a freelancer. There are literally 2000+ new projects that are posted every single freakin' day, no lie!