PDA

View Full Version : duplicateMovie() help!


cardiac7
12-06-2004, 10:35 PM
Ok.... So i have this string that I am splitting up into an array, now I need to loop through that array and create/duplicate a MC for each [i] in that array. So far I have this, but its not making new MC's?


// Where "brand" is my array.... and "brandMC" is the MC I want duplicated

for (i in brand) {
xPos +=20;
yPos +=20;
brandMC.duplicateMovieClip("brand"+i, this.getNextHighestDepth(), {_x:xPos, _y:yPos});
trace(brand[i]);
}
///end array loop



But nothing happens???? The only thing I have in the brandMC is a dynamic textfield that I will need to figure out how to populate with the brand[i].value.

Any suggestions? Ultimately I am going to have them randomly move about the stage.

Thanks AS!

emergency_pants
12-08-2004, 04:13 PM
I've tested this script and it seems to work here:

var xPos:Number = 20;
var yPos:Number = 20;
var brand_array:Array = new Array();
//
brand_array = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
//
for (i in brand_array) {
xPos += 20;
yPos += 20;
brand_mc.duplicateMovieClip("brand"+i, this.getNextHighestDepth(), {_x:xPos, _y:yPos});
this["brand"+i].label_txt.text = brand_array[i];
trace(brand_array[i]);
}

Did you declare your xPos and yPos variables before you started adding to them?
Have you declared your array correctly and tested to make sure it has content before the loop is run?

That's all I can think of for now.... but hopefully it'll help? :)