-
Using strings in paths
I have a for loop which duplicates a movieclip called "mc" in the root. mc has a text field called "tf" inside and I want to load the different texts that I get from an external file to every different copy of the MC "mc". I have written a code but it seems not to work.. Can you help me?
-----
for(i=0; i<Number(loadVarsText.num);i++) {
// num is the number of variables
duplicateMovieClip(mc,"mc"+i,i+1);
lev = "_level"+(i+1);
mec = "mc"+i;
v = "var"+i;
eval(lev).eval(mec).tf.text = loadVarsText.eval(v);
setProperty("mc"+i,_x,100);
setProperty("mc"+i, _y,i*15);
}
-----
Thanx..
-
What part doesnt work ?
loading the diffrent texts in the the mc's ?
or duplicating the mc's ?
a example might help to understand the problem
-
in fact I don`t know which part does not work. I think the eval(..) part doesnot work. This is the only code that I use..
-
The eval functions return "undefined"...
-
1 Attachment(s)
I'm not 100% sure of what your code was trying to do so I adapted it a bit to make it more simple but hopefully you'll still get the idea:
for(i=0; i<10;i++) {
duplicateMovieClip(mc,"mc"+i,i+1);
mec = eval("mc"+i);
mec.tf = i;
setProperty("mc"+i,_x,100);
setProperty("mc"+i, _y,i*50);
}