Unfortunately, I don’t feel I know AS3 well enough and am a little bit rusty on my AS2. Can any one help me figure out what I'm doing wrong?
I created a movie clip which holds the dynamic textfield and placed 30 instances on the stage. Each instance is successively named "cityName[i]" where i is a number from 1-30. I've tried setting the instances as both buttons and movie clips. I also tried setting both the .text and.htmlText attributes, but neither works. I’ve embedded the fonts on the dynamic text field. I’ve also tried changing the field to input instead of dynamic but that doesn’t work either. I’ve been tracing things to try to debug, but haven’t found the issue yet.
Here's the code:
- Code: Select all
//load XML data
var citiesData:XML = new XML();
citiesData.ignoreWhite = true;
citiesData.load("30cities.xml");
citiesData.onLoad = parseXMLData;
//define parse function
function parseXMLData(success:Boolean):Void {
//make sure data is loaded and usable
if (success && this.status == 0) {
var theRoot:XMLNode = this.firstChild;
//trace("the root node is called " + theRoot.nodeName);
//trace("\tnumber of child nodes: " + theRoot.childNodes.length);
for (var i:Number = 0; i < theRoot.childNodes.length; i++) {
var theCities:XMLNode = theRoot.childNodes[i].firstChild.firstChild;
//trace ("\t\t" + theCities.nodeValue);
var city:Array = new Array();
//create array for name
city[i] = new Object();
city[i].cityName = new Array();
//populate with city names
city[i].cityName[i] = theCities.nodeValue;
//SO FAR EVERYTHING TESTED WORKS
//create array for buttons
var buttonLabels:Array = new Array();
for (var b:Number = 0; b < city[i].cityName.length; b++) {
buttonLabels.push("cityLabel" + [i + 1] + ".cityName_txt");
//_root[buttonLabels[i]].htmlText = "Text Here";
}
//populate button text fields with names
buttonLabels[i].htmlText = city[i].cityName[i];
//THIS PART DOESN’T WORK: I CAN’T GET THE NAMES TO FILL THE TEXTBOX INSIDE THE MOVIE CLIP I’M USING AS A BUTTON
}
}
else {
trace("Problem loading XML document");
trace("The status code is: " + this.status);
}
}
