TechiWarehouse.Com


Top 3 Products & Services

1.
2.
3.

Dated: Aug. 12, 2004

Related Categories

Flash

Written By Cathy Jenkins (web designer) on: March 10, 2004

Files: FLA Source Code or view the movie/demo

Introduction

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.

Part 1

  1. Create a movie apart from the main stage of a graphic tweened off the stage.
  2. Create an instance of the movie mentioned above. This will be placed in the stage by you.
  3. Specify a name for the instance eg "myflake".
  4. 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.

Macromedia Flash MX

Action Scripting Time

  1. Specify the function name for your action. "billy" is used in my example.
  2. Declare the original instance eg "myflake" to be stationary.
  3. Create a loop and specify how many times to execute it in that code block. I chose 25.
  4. Replicate the original movie ie "myflake"
  5. Call each instance of the movie "myflake" and the iteration of the loop. Eg. "myflake1", "myflake2, "myflake3".
  6. 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.
  7. 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)
  8. Scaling by proportion requires us to scale both X and Y.
  9. Change the opacity with "myscale" to create the effect of distance.
  10. End the code.
  11. Put a stop after the first frame in your movie so it does not iterate.
  12. 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:
    on (release)
    {
    billy();
    }

Frame 1 Action Scripting

sn1._visible = false;
sn2._visible = false;
sn3._visible = false;

function billy()
{


for (x=1;x<25;x++)
{

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);
myColoredObject.setRGB(myColor);
}

}
stop();


Button Action Scripting

on (release)
{
billy();
}

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!


Previous Article

Next Article