In previous versions of ActionScript, there were a couple of classes who had the capability of loading external text, namely LoadVars and XML. The loading responsibilities of these classes has moved to one single class in ActionScript 3, URLLoader (flash.net.URLLoader). This class is a lot like LoadVars. The big difference is that it is used for XML since the responsibility of loading XML from an external source has been removed from the XML class. Instead, you would load the text with URLLoader and then give that text to an XML object for parsing.
Like LoadVars, URLLoader has a load() method that is used to load text from an external source. This accepts 1 argument, a URLRequest instance (NOT a URL string). You can then use events from URLLoader to determine when the loading is complete. When complete, the text loaded is available in the data property of URLLoader.
// …
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, xmlLoaded);
var request:URLRequest = new URLRequest(“file.xml”);
loader.load(request);
//…
function xmlLoaded(event:Event):void {
var myXML:XML = new XML(loader.data);
//…
}
You might also like
| Loading Text and XML with URLLoader in AS3 In previous versions of ActionScript, there were a couple of classes who had the capability of loading external... | Loading XML data using ActionScript 3.0 Using XML is one of the best ways for structuring external content in a logical format that is easy to understand,... | Using ActionScript 3.0 with PHP Loading External Variables Creating dynamic websites which combine the power of Flash or Flex with PHP is easier than ever with ActionScript... | Writing Inline XML in AS3 In ActionScript 3, you can define XML variables using inline XML in your script. You don't even need to enclose... |





