Groups | Blog | Home
all groups > flash actionscript > june 2006 >

flash actionscript : getting an XML file into an Array


Steve Robertson
6/25/2006 5:49:51 PM
Have gotten an xml file to load properly (as verified by a trace), but
can't seem to figure out how to load it into a single dimension array??

xml file format is:
<item name="aaa.swf" />
<item name="bbb.swf" />
etc.

all I want is to end up with an array of the .swf names.
Steve R.

NSurveyor
6/26/2006 2:20:56 AM
Use something like:

<items>
<item name="aaa.swf" />
<item name="bbb.swf" />
</items>

for your XML.

And in Flash, use:

myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function() {
var swf = [];
for (var i = 0; i<this.firstChild.childNodes.length; i++) {
swf[i] = this.firstChild.childNodes[i].attributes.name;
}
trace(swf);
};
myXML.load("FILENAME.xml");
Steve Robertson
6/26/2006 12:13:22 PM
Thanks! I wasn't understanding the nodes aspect of the XML. Got it to
working beautifully.
NSurveyor
6/26/2006 8:25:40 PM
AddThis Social Bookmark Button