PDA

View Full Version : XML Value to text field



flabbygums
September 28th, 2007, 03:35 PM
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXML);
loader.load(new URLRequest("file.xml"));

function loadXML(e:Event):void {
var myXML = new XML (e.target.data);
for each (var name:XML in myXML..name)
trace (name)
trace (typeof name)
activeParts_txt.text = name
}
The above traces this: but my text field only shows "Dartboard"

Garage Items
Big Engine
Flames
Graffiti
Calendar
Oil Cans
Tool Chest
Dartboard
xml

But if I switch the order of the two trace statements to:

trace (typeof name)
trace (name)
It traces this:

xml
xml
xml
xml
xml
xml
xml
xml
Dartboard


In both cases my text field only displays "Dartboard". I guess I need to convert this XML it a string somehow? I tried setting name to an XMList but that didn't do much.

Thanks.

hakukaji
September 28th, 2007, 04:00 PM
it just looks like you are re-writing activeParts_txt.text and at the end it shows the last value. if you want all of them try activeParts_txt.text += name

flabbygums
September 28th, 2007, 06:50 PM
That got me on the right path.. that worked but threw an error that it's much slower than this:
getActiveParts_txt.appendText(name)

Thanks!!!