• flickr
  • linkedin
  • twitter
  • rss
Loading XML into flash as an XML object

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:

Larry's a 30-something chap interested in travel, being a dork and changing the world via less boring training.

Leave a reply