Flash Script - Create Duplicate Movieclips


Download the sample files here.

Note that this tutorial assumes that you know how to create buttons and text fields.

1. First, create a button and label it "make clones".

2. Create a text field as shown in the above movie. Give it a variable name "no_clones".

3. Create a movie clip of your choice, which we can duplicate. I created a circle object with a gradient.

4. Give the movie clip an instance name of "clone".

5. Now, in the default layer’s first key frame, insert this action:

// set variable clips=value in text field.  clips = no_clones;

6. Right click the button and insert these actions:

/on (release)   {  // get the current x pos of the clone movie  mov_x = getProperty("/clone",_x);  //Check if the text field is empty if empty set it to 1  if(no_clones == "")  {  no_clones = 1;  }  // Use for loop to remove existing movie clip  for(i=1; i<=clips; i=i+1)  {  removeMovieClip ("/clone" add i);  }  // Use for loop to create duplicate movies.  for (i=1; i<=no_clones; i=i+1)  {  mov_x = mov_x + 50;  duplicateMovieClip ("/clone", "clone" add i, i);  setProperty ("/clone" add i, _x, mov_x);  }  //set variable clips = no_clones.  clips = no_clones;  }

I’ve commented the above script so that it’s easier for you understand. But that’s all you need to do: it’s time to test the movie.

Learning to create duplicate movie clips in flash is very usefull. It can be used to create a lot of effects — happy experimenting!

Replay

Category: software Time: 2003-04-28 Views: 1
Tags:

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.221 (s). 12 q(s)