Loading XML into flash as an XML object

loading XML into flash as an XML object

// xml loader
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, loadXML);
xmlLoader.load(new URLRequest("leadership_development_framework.xml"));
function loadXML(event:Event):void
{
  xmlData = new XML(event.target.data);
}

Further to that, once you’ve your xmlData filled, you can chop it up with XMLList to make sub-listings for easier management.

For example, say I have an xml formatted like so:

<xml>
  <main>
    <item>
      <title>Item 1</title>
    </item>
    <item>
      <title>Item 2</title>
    </item>
  </main>
</xml>

To make an XML list of just the content within the first item, I could make an subset of data with XMLlist – ie.

var titleList:XMLList = xmlData.main.item[0].*;

Great tutorial on Kirupa about it which is much more instructional, this is more of a mental primer for myself:
http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm

Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑