AS2 to AS3 Baby Steps - Part 2 - Loading xml files

Reynaldo November 2nd, 2007

Loading xml files in AS3 requires the use of the new URLLoader class. The URLLoader Class downloads data from a URL as text or binary data. It basically downloads all the data before making it available to actionscript. The URLLoader would then subscribe to the Event.COMPLETE event and would call the parsing function once the event is fired.

This is what the code looks like:

var strXML:String = "myxmlfile.xml";
var objLoader:URLLoader = new URLLoader();
 
objLoader.addEventListener(Event.COMPLETE, parseXML);
objLoader.load(new URLrequest(strXML));
 
function parseXML($event:Event):void
{
     trace("Loading Complete, time to parse.");
}

Trackback URI | Comments RSS

Leave a Reply

  • Friends

  • Props

  • Donations

  • website counter
  • Archives

  • Feedburner