Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

duplicate movie clips-drag and drop

Status
Not open for further replies.

tziviak

Technical User
Oct 10, 2002
128
US
I have a movie clip that the user-can drag onto the grid-and move around the grid. But, I want the user to be able to drag onto the grid as many of the item as he/she wants to-so probably the best way to do it is to duplicateMovieClip on the fly-but then how do I keep track of them-and give each one their own name, onclick event...?
til now I have an array with 10 copies of the same movieclip-I'm sure there is a more efficient way to do it with duplicatemovieClip-but I'm not sure how-any ideas?
thank you
 
You can still use an array with duplicated clips - create the new clip on the fly then push it into the array.

Code:
duplicateMovieClip("clip", "clipCopy", 2);
clipArray.push('clipCopy');

You can keep track of all the clips by using the array's length property.
 
all of the clips can have the same name?
 
Technically yes and then you could just refer to them by their array indices, but you could add a counter variable too when naming the clips to keep the instance names unique:

Code:
duplicateMovieClip("clip", "clipCopy"+num, 2);
clipArray.push('clipCopy');
num++;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top