Posted by: Yogesh Puri on: September 23, 2008
I have developed this XMLUtility class in conjunction with a CustomEvent Class which returns me the loaded XML/String Data along with the complete event firing. You can download the sources from here. Following is the code you need to write when you want to load this class
//------------ Import Classes
import com.flexcomps.utils.CustomEvent;
import com.flexcomps.utils.XMLLoaderUtil;
//-------- Create instance of loader class
var xmlLoader:XMLLoaderUtil = new XMLLoaderUtil();
xmlLoader.addEventListener(CustomEvent.ONLOADED, onXMLLoaded);
xmlLoader.load(xmlPath);
//----- Method to handle the returned data
private function onXMLLoaded(evt:CustomEvent) {
xmlData = evt.data as XML;
trace(xmlData);
}
[...] Visit link: AS3 XML Loader Utility Class [...]
October 6, 2008 at 5:03 am
Nice one. Even though it’s handy is there much benefit to using this over existing classes? ie.
var xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoaded);
xmlLoader.load(new URLRequest(xmlPath));
private function onXMLLoaded(evt:Event) {
xmlData = XML(xmlLoader.data.toString());
}