PDA

View Full Version : Making unlimited number of instances


payt
03-13-2006, 12:14 PM
Hi,

I have 4 movie clips. I would like to create unlimited instances of these which will be layered on top of each other. Basically they have drag and drop code on them. So when one is dragged away there is another directly beneath it ready to be dragged. I dont want to use a button to do this, i would just like some code that is ran at the start that produces duplicates.

Thanks in advance

Cota
03-13-2006, 01:01 PM
Are you sure you want to do that...unlimited movieclips that are autogenerated without user control?? thats going to be a process overload..

payt
03-13-2006, 01:23 PM
you are right, i dont want that actually. Ok so i would like it to create 20 of each? How would i do that?

Thanks

Cota
03-13-2006, 01:26 PM
what are the movieclip instance names that you wish to duplicate?

payt
03-13-2006, 01:28 PM
testarea
square
circle
rectangle


Thanks

Cota
03-13-2006, 01:41 PM
for (i=0; i>=19; i++){
duplicateMovieClip ("testarea", "testarea" + i, getNextHighestDepth());
duplicateMovieClip ("square", "square" + i, getNextHighestDepth());
duplicateMovieClip ("circle", "circle" + i, getNextHighestDepth());
duplicateMovieClip ("rectangle", "rectangle" + i, getNextHighestDepth());
}

This is off the top of my head, but it should work..

payt
03-13-2006, 01:48 PM
Hmmmm doesnt seem to work. I added this new script on a new layer called "actions". Would that be the correct place to add it? When i drag the original object away there are no more objects underneath it. Thanks for your help so far, its really apreciated and i will keep trying.

Thanks

Cota
03-13-2006, 01:51 PM
assuming those are the instance names of the original movieclips, I dont see why it wont work...

Cota
03-13-2006, 01:55 PM
sorry

for (i=0; i>=19; i++){
duplicateMovieClip (_root.testarea, "testarea" + i, getNextHighestDepth());
duplicateMovieClip (_root.square, "square" + i, getNextHighestDepth());
duplicateMovieClip (_root.circle, "circle" + i, getNextHighestDepth());
duplicateMovieClip (_root.rectangle, "rectangle" + i, getNextHighestDepth());
}

payt
03-13-2006, 02:02 PM
Hmmm unfortunetly it does not work. I cant see why it wont myself. I did start the project in flash 8 but at the moment its running in mx2004 because i had to switch computers

Cota
03-13-2006, 02:07 PM
are the movieclips located on the _root, or in some other path?

payt
03-13-2006, 02:20 PM
They are just in the one .fla that i am working with all on frame 1 of the movie.

Thanks

::plankl::
03-13-2006, 02:32 PM
not good at AS but, why not to create duplicate of instance only when is draged away. don't know the coding so...

Cota
03-13-2006, 02:34 PM
in theory, this should work

for (i=0; i>=19; i++){
duplicateMovieClip (_root.testarea, "testarea" + i, getNextHighestDepth());
duplicateMovieClip (_root.square, "square" + i, getNextHighestDepth());
duplicateMovieClip (_root.circle, "circle" + i, getNextHighestDepth());
duplicateMovieClip (_root.rectangle, "rectangle" + i, getNextHighestDepth());
}

payt
03-13-2006, 02:41 PM
I will keep trying. Thanks guys