Actionscript 3: assigning variable name to XML data to populate text fields -
here's xml file:
<?xml version="1.0" encoding="utf-8"?> <root> <driverone>mario andretti</driverone> <drivertwo>luigi andretti</drivertwo> </root>
super simple - have 2 names, driverone , drivertwo.
and here's actionscript 3:
import flash.events.event; import fl.controls.label; import flash.events.mouseevent; import flash.net.urlloader; import flash.net.urlrequest; stop(); var myxml:xml; var myloader:urlloader = new urlloader(); myloader.load(new urlrequest("bulkfuel.xml")); myloader.addeventlistener(event.complete, processxml); function processxml(e:event):void { myxml = new xml(e.target.data); trace(myxml.driverone); trace(myxml.drivertwo); } //define variable xml data var firstdriver:string = string(myxml.@driverone); var codriver:string= string(myxml.@drivertwo); //populate text fields variables driverone_txt.text=string(firstdriver); drivertwo_txt.text=string(codriver);
everything works down trace function. reason, , know it's stupidly simple can't seem find it, can't these names load text fields.
@
- attribute. use myxml.driverone
.
Comments
Post a Comment