I have 10 dynamic text fields on my stage named , xmlTxt1, xmlTxt2, xmlTxt3,etc.
I’d like to loop through and assign a fontsize attribute from an XML file to each dynamic text box.
I’d like to use a variable , myTextField = xmlTxt, and loop through adding 1 each time to xmlTxt to access the dynamic text field names.
Something like this:
var textFieldName = “xmlTxt”;
myFormat=new TextFormat();
total = xmlNode.childNodes.length;
for (i=0; i < total; i++)
{
myFormat.size= Number(xmlNode.childNodes[1].attributes.fontsize); /* set text field size from XML - no problems with this /
textFieldName.text=xmlNode.childNodes.attributes.textCopy; /* This is where it goes wrong. /
textFieldName.setTextFormat(myFormat);
var textFieldName = “xmlTxt” + i;
trace(textFieldName) / this shows variable is, xmlTxt1, xmlTxt2, etc. What’s wrong here? */
}