AS3.0 - How do I store an XML table into a Flash Array?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arcanisjk
    New Member
    • Jan 2010
    • 3

    AS3.0 - How do I store an XML table into a Flash Array?

    Code:
    <?xml version="1.0"?>
    <posts>
    <item>2</item>
    <item>3</item>
    </posts>
    What do I need to type in Actionscript so that I can put this information into an Array?

    I need to be able to trace out the individual elements in separate textboxes in Flash. As far as my knowledge goes, I only thought of this method of doing it.

    Is there any better method as to how I can go about doing this?

    Hope to get some responses soon. (:
  • iamfletch
    New Member
    • Jan 2010
    • 18

    #2
    Heres the code, assuming the file is called file.xml and you want to load it from a file.
    Code:
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, loadXML);
    loader.load(new URLRequest("file.xml"));
    var xml;
    function loadXML(e:Event):void
    {
            xml = new XML(e.target.data);
            trace(xml); // Outputs the whole file
    		for (var i in xml.item)
    		{
    			trace(xml.item[i]);
    		}
    }

    Comment

    Working...