Morning all,
I'm trying to get my head round AS3 and using loaded external XML, but tutorials and guides seem to be very vague on the subject.
What I'm trying to do is load an xml file, transfer specific elements / attributes to variables, then use those variables to load images / fill text boxes.
So I have my XML Loader:
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("bdata.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
myXML = new XML(e.target.data);
}
I now need to get this into a variable to use when loading images:
var imgB1Request:URLRequest = new URLRequest("Images/"+ Variable +".png");
var imgB1Loader:Loader = new Loader();
imgB1Loader.load(imgB1Request);
_B1.addChild(imgB1Loader);
Providing I declare the variable before loading the XML EG:
var img1:string
How do I save an element or attribute into that variable?
sample XML:
<game>
<bTeam>Blue Team</bTeam>
<bPlayer1 title="Player 1 Blue">Char1</bPlayer1>
<bPlayer2 title="Player 2 Blue">Char2</bPlayer2>
<bPlayer3 title="Player 3 Blue">Char3</bPlayer3>
<bPlayer4 title="Player 4 Blue">Char4</bPlayer4>
<bPlayer5 title="Player 5 Blue">Char5</bPlayer5>
</game>
thanks in advance, or if you can recommend somewhere that also explains it, that would also be appreciated.
No comments:
Post a Comment