View Full Version : question FMX duplicate MOVIE CLIPS
jagunco
August 3rd, 2003, 04:27 PM
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);
Johnny64
August 3rd, 2003, 05:03 PM
Hoi
just access them with
_root.newClip-and a num 1-10
;)
jagunco
August 3rd, 2003, 05:38 PM
but it dosenīt work
any sugestions
Johnny64
August 3rd, 2003, 05:50 PM
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)
}
;)
ahmonra
August 3rd, 2003, 06:36 PM
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:
_root.xyzMC.duplicateMovieClip("blah"+i,x);
newClip = eval("_root.xyzMC.blah" + i);
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:
_root.xyzMC.duplicateMovieClip("blah"_i,x);
eval("_root.xyzMC.blah" + i)._y;
It saves the trouble of creating a reference object and all that. Lemme know if that helped.
Shaheeb R.
pom
August 4th, 2003, 11:47 AM
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 :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.