Flash tutorials
Home 3D (2) Actionscripting (65) Animation (100) Audio (4) Drawing (7) Full flash sites (4) Getting Started (15) Navigation (25) Special Effects (52) Text Effects (38)

Duplicate your image many times using a little action script code

26.2.2009, 12:6    Total views: 7899

Using this thoroughly explained, detailed flash lesson, you will see how to Duplicate any image many times using a little action script code. Using this lesson, you will also learn how to import any image into a flash stage, how to convert it into a Movie Clip Symbol, how to create instance name and much more!



Example:



Step 1

First save the image below, which we will use for this lesson!





Step 2


Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the width of your document to 300 pixels and the height to 225 pixels. Select white as background color.



Step 3

Call the current layer image. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!

Step 4

Choose now File > Import > Import to stage (Ctrl+R) and import the image that you just saved in step 1!

Step 5

While the image is still selected, press F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.



Step 6

While the new made movie clip is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip image. See the picture below!



Step 7

It's time for action script, so select the first frame of layer image and go to the Action Script Panel (F9). After that, enter this code inside the actions panel:

dupMovie = function () {

for (i=0; i<100; i++) {

image.duplicateMovieClip("image"+i, i, {_x:Math.random()*300, _y:Math.random()*225, _alpha:Math.random()*100});
with (eval("image"+i)) {

_xscale = _yscale=Math.random()*300;

}

}

};
dupMovie();

That's it!

Test your movie and enjoy!

Download source file (.fla)

Have questions about this tutorial?
Visit our friendly Community Forums!
Digg it! Add this tutorial to del.icio.us! Furl it! Add this tutorial to reddit! Spurl it! Add this tutorial to technorati!

Top tutorials

1. Advanced full flash site - Part 1
Total views: 221535

2. Water effect
Total views: 166040

3. Photo slide show
Total views: 153641

4. High-tech city animation
Total views: 151459

5. Special Picture Effect
Total views: 146246

Related links