I’m not sure exactly how to word or what to search for to accomplish what i’m wanting. I’m loading XML into dynamically created text fields. I’ve got everything working properly in that aspect. Now, for example, the XML has 5 different events, each with a “name”, “city” & “date”. I can get the first event to display all the variables. How do I get Flash to continue to output the rest of the XML file into text fields without creating dynamic fields for every XML node?
//Create XML loader and load it
var eventsXML:XML;
var xmlReq:URLRequest = new URLRequest("xml/test.xml");
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(xmlReq);
xmlLoader.addEventListener(Event.COMPLETE, displayEvents);
//Create dynamic textfields
var what:TextField = new TextField();
var where:TextField = new TextField();
var when:TextField = new TextField();
//Set auto size to textfield & align the text to the left of the box
what.autoSize = TextFieldAutoSize.LEFT;
where.autoSize = TextFieldAutoSize.LEFT;
when.autoSize = TextFieldAutoSize.LEFT;
//Create text fields and insert the XML data into them.
function displayEvents(event:Event):void {
eventsXML = new XML(xmlLoader.data);
//Format EventName textfield
var whatFormat:TextFormat = new TextFormat();
whatFormat.font = "Arial";
whatFormat.bold = true;
whatFormat.color = 0x003E7E;
whatFormat.size = 18;
what.defaultTextFormat = whatFormat;
//Format City & Date textfields
var citydateFormat:TextFormat = new TextFormat();
citydateFormat.font = "Arial";
citydateFormat.color = 0x3333333;
citydateFormat.size = 14;
where.defaultTextFormat = citydateFormat;
when.defaultTextFormat = citydateFormat;
//Add dynamic textfields to the stage
addChild(what);
addChild(where);
addChild(when);
//Insert the instructed XML into the proper text fields
what.text = eventsXML.Event[0].EventName;
what.x = 32;
what.y = 50;
where.text = "Location: " + String(eventsXML.Event[0].City);
where.x = 32;
where.y = 81;
when.text = "Date: " + String(eventsXML.Event[0].EventStartDate);
when.x = 200;
when.y = 81;
}