Basic XML with Flash
- March 6th, 2005
- Write comment
Someone had asked me today how to use XML with Flash. He is interested in using a XML file to configure a game he wants to write. He wants to write a Monopoly-like game but be able to quickly reconfigure the game board based on the location he wants to use. I wrote up a very basic sample file for him and I thought I would share it here.
[as]
var myXML:XML = new XML(‘
trace(“Number of board nodes=”+myXML.firstChild.childNodes.length);
numNodes = myXML.firstChild.childNodes.length;
for (i=0;i
}
[/as]
Now this sample uses XML directly within the ActionScript, but it is done the same way using external XML, except you would have a myXML.load(“config.xml”) and then need a myXML.onLoad function handler.