Please don’t get scared by the “XML” This problem is quite simple.
I’m loading paths to several XMLs from a single XML. For example,
<XML>./directory/test.xml</XML>
Simply put, I’m loading a main xml, named “Main_XML”, which holds the names of several XMLs I want to load afterwards, hopefully recursively using the “xmlLoader” function below.
My problem is quite simple, it doesn’t finish loading “Main_XML” before it starts (and finishes) loading the other XMLs. Is there a trick I can do here to ensure everything is loaded before continuing?
public function xmlLoader ( url:String ):Void {
var myXML = new XML();
myXML.ignoreWhite = true;
myXML.parent = this;
myXML.onLoad = function (success:Boolean) {
var xml_loader:XML2Object = new XML2Object(); // initialize the XML2Object class
// get the native flash object using the parseXML method, pass the XML itself as argument
if(success) {
this.parent.xmlInfo = xml_loader.parseXML(this); // parse the Object
this.parent.setXMLInfo( this.parent.xmlInfo ); // call the function to handle the objs
}
}
myXML.load( url );
}
/**
* Called only after XML is fully loaded, from the XML loading function
* @param xmlObj: XML object created by xmlLoader func
**/
public function setXMLInfo( xmlObj:Object ):Void {
if ( xmlInfo.GAMEUI.attributes.name == "Main_XML" ) {
loadAdditionalXMLS( xmlObj );
}
else {
trace ( "Call function, no XMLs left to pass" );
// Parse additional XMLs and THEN call this function
testFunction( );
}
}