PDA

View Full Version : increment names of movie clips with duplicateMovieClip


civicparadox
01-09-2003, 05:57 AM
I still can't figure out the syntax of actionscript. I have a movie clip called "screen0" and a global variable named "screenDup" which is initiated to 0. When a button is clicked, I want to duplicate screen0 with

duplicateMovieClip(_root.screen + _global.screenDup, "screen" + _global.screenDup++, 2);

After that, I would like to perform a fuction on the previous screen (ie screen0).

upShrink("screen" + _global.screenDup);

As you probably guessed, it doesn't work and I'm pretty sure it's because of the syntax. I have tried various combos and nothing is doing it for me. Please help this hopeless coder. Thanks.

farafiro
01-09-2003, 08:00 AM
first let's look at the syntax of the script, what it should beon(release){
duplicateMovieClip(target, "newName", depth)
//or
target.duplicateMovieClip("newName", depth)
}
so, there must be a movie present on the stage that it will have this script ------ first rule

second if we want to duplicate it dynamicly, we need 2 things
=> a new Name for each one
=> a new Depth for each one

so, we can do that dynamicly with two ways//***********First way****************
//on the root
// Mc is the movie name
//the variable's name is counter
counter = 0
//on the button
on(release){
counter++
mc.duplicateMovieClip("mc"+counter,counter)
}
//************Second way**************
on(release){
mc.duplicateMovieClip("mc"+counter++,counter++)
}just you need to add a new coordinates to it

civicparadox
01-11-2003, 03:48 AM
So if I wanted to perform a function on the new movie clip, I would just have to type

function("mc"+counter);

right?
I just tried that and it didn't work.

farafiro
01-12-2003, 07:57 AM
no, try thisfunction(function name){
//anything here the call it with the way below
//or
this["mc"+counter]
}
//if the first way
this["mc"+counter].onEnterFrame = function(){
//blah blah
}