Duplicating movie clips

Is it possible to duplicate a movie clip within a movie clip in the same loop?

Lets say I have 2 MCs, Inside and Outside.

I have the Variable

NumOutside = 3 this is the number of times the outside MC will be duplicated

And the Array

NumInside[1] = 2 this is the number of times that the Inside MC will be duplicated within Outside1
NumInside[2] = 1 this is the number of times that the Inside MC will be duplicated within Outside2
NumInside[3] = 3 this is the number of times that the Inside MC will be duplicated within Outside3

Is there any way in my for command to target
_root.Outside1 when I = 1 and duplicate Inside 2 times
_root.Outside2 when I = 2 and duplicate Inside 1 time
_root.Outside3 when I = 3 and duplicate Inside 3 times

I’ve tried the following code but have no way to reference the duplicated versions of Outside:

for (i=1;i!==NumOutside;i++){
	_root.Outside.duplicateMovieClip("Outside"+i,i);
	setProperty("_root.Outside"+i,_y,i*30);
	for (j=1;j!==NumInside*;j++){
		/* need something like _root.Outside+i+.Inside.duplicateMovieClip("Inside"+j,j); */
}

duplicated clips appear on the same timeline as the clip they’re duplicating. you call it in such a way as to change that. you can approach the problem a little differently however.

one solution would be to put “inside” in “outside”. then you get one copy by default and duplicated clips will appear within “outside”.

another approach would be to use attachMovie rather than duplicateMovieClip. it’s a little more flexible in terms of where you put stuff.

I’m not sure if I understand you or if you understand me. The “Inside Movie Clip” is Located inside the “Outside Movie Clip” I am duplicating the Outside movie clip 3 times but inside each one of those duplicates I want to duplicate the Inside Movie Clip a different number of times so:

Outside1 contains Inside1 and Inside2
Outside2 contains Inside1
Outside3 contains Inside1, Inside2, and Inside3

what I am asking is how I duplicate the Inside clips within the duplicated outside clips without having to target each created clip individually. I would like to use a loop similar to the one I used to create the outside clips.

Nevermind, I figured it out. Dit it like this:

for (i=0;i!==OutsideNum;i++){
	_root.Outside.duplicateMovieClip("Outside"+i,i);
	setProperty("_root.Outside"+i,_y,i*30);
	for(j=0;j!==InsideNum*;j++){
		duplicateMovieClip("_root.Outside"+i+".Inside","Inside"+j,j+10)
		setProperty("_root.Outside"+i+".Inside"+j,_y,(25+(j*25)-(InsideNum**25)));
	}
	removeMovieClip("_root.Outside"+i+".Inside");
}
_root.Outside.removeMovieClip();

aha, i didn’t get the part where you’d already put “inside” inside “outside”.

you can store a movie clip in a variable to avoid evaluating it each time (apparently a costly operation processor-wise).

you could amend your code to use this technique like so:


for (i=0; i < OutsideNum; i++){
	_root.Outside.duplicateMovieClip("Outside"+i,i);
	outerClip = _root["Outside"+i];
	outerClip._y = i*3;
	for(j=0; j < InsideNum*; j++){
		duplicateMovieClip(outerClip.Inside","Inside"+j,j+1);
		outerClip["Inside"+j]._y = 25+(j*25)-(InsideNum**25));
	}
	removeMovieClip(outerClip.Inside);
}
_root.Outside.removeMovieClip();