Hello! I’m having a problem while assigning variables into dynamically-created MovieClips. Here’s a pseudo-code of what I’m trying to achieve.
var myArray:Array = [];
// Create a movieClip for each element in XML.
for each(var tempXML:XML in allXML.details){
var myMC:MovieClip = new MovieClip();
myMC.y = myArray.length * 20;
// Line above easily changes the y value of the MC
// because the y variable is already declared in the MC class
myMC.indexNumber = myArray.length;
// Line above does not pass indexNumber variable into myMC
// How can I assign new variables into this MC?
this.stage.addChild(myMC);
myArray.push(myMC);
}
I need the movie clips to contain their index values as a variable within them. I’ve tried several approaches, including declaring the variable names within the MC itself, but that doesn’t work either.
I would be very grateful if anyone could help me achieve this, thanks!