Question FMX duplicate MOVIE CLIPS

hi I have this code that duplicates an MC on stage , my problem is , after the duplication i know every MC as a unique name, but I can´t access them, I don´t understand why, can someone explain tthis to me please tahnks

/////

button_mc._visible = false;

var maxClips = 10;

var i = 0;

function addClip() {

i++;
	newClip = _root.button_mc.duplicateMovieClip("newClip"+i, i);
	newClip._y = i*(newClip._height+10);
 maxClips variable
if (i>=maxClips) {
	//clear the interval and stop running this function
	clearInterval(addClipsInterval);
}

}

var addClipsInterval = setInterval(addClip, 100);

Hoi

just access them with
_root.newClip-and a num 1-10

:wink:

but it dosen´t work

any sugestions

if you are accessing it right away the newClip5 will not be make jet so you will have the access when the Interval is finished
try this…


_root.onEnterFrame = function(){
trace(newClip5)
}

:wink:

I’ll bet your problem is that you are trying to use newClip to access each newly duplicated MC. I think the problem is that newClip isn’t an object like you want it to be. You need to first duplicate the MC and then reference it into your newClip using eval(). Something like this:

[AS]
_root.xyzMC.duplicateMovieClip(“blah”+i,x);
newClip = eval("_root.xyzMC.blah" + i);
[/AS]

Now try to access something like newClip._y or whatever. Im like 99% sure thats the right path for you. Whenever I try something like this, I use code like:

[AS]
_root.xyzMC.duplicateMovieClip(“blah”_i,x);
eval("_root.xyzMC.blah" + i)._y;
[/AS]

It saves the trouble of creating a reference object and all that. Lemme know if that helped.

Shaheeb R.

Put them in an array:

button_mc._visible = false;
myClips = [] ;
var maxClips = 10;

var i = 0;

function addClip() {
	i++;
	newClip = _root.button_mc.duplicateMovieClip("newClip"+i, i);
	myClips.push ( newClip ) ;
	newClip._y = i*(newClip._height+10);
	if (i>=maxClips) {
	//clear the interval and stop running this function
		clearInterval(addClipsInterval);
	}
}

var addClipsInterval = setInterval(addClip, 100); 

Then you can access them with myClips[2] for instance.

pom :slight_smile: