tags:

views:

213

answers:

2

I want to load 3 unique xml files, then parse them individually.

Now if all 3 xml files been successfuly loaded & parsed. I want to go to frame 10 otherwise stop and displaymessage.

xml.onLoad = function(success) { is for one xml

if I have three or more XMLs how do I know when all of the has been successfuly read and processed, to navigate futher.

please provide sample codes.

+1  A: 

One way you could do it is keep a flag for each XML document that's set to true once it's done loading. Also write a check function that checks all 3 flags and goes to the frame if all 3 are set to true. For each loader's success event set the flag for that XML document and then call the check function.

Here's some rough pseudocode:

var xml1:XML;
var xml2:XML;
var xml3:XML;

var xml1Loaded:Boolean = false;
var xml2Loaded:Boolean = false;
var xml3Loaded:Boolean = false;

function checkAllLoaded():void {
  if(xml1Loaded && xml2Loaded && xml3Loaded) {
    gotoFrame(10);
  }
}

xml1.onLoad = function(success:Boolean):void {
  if(success) {
    xml1Loaded = true;
    checkAllLoaded();
  }
}
xml2.onLoad = function(success:Boolean):void {
  if(success) {
    xml2Loaded = true;
    checkAllLoaded();
  }
}
xml3.onLoad = function(success:Boolean):void {
  if(success) {
    xml3Loaded = true;
    checkAllLoaded();
  }
}

xml1.load();
xml2.load();
xml3.load();

Obviously you should add handling for loading errors and use the right methods for loading the XML and jumping to a frame, but this should give you an idea of how it can be done.

Herms
A: 

By far the easiest way is to just make three separate URLLoaders.

It depends on what sort of content is in each XML file on how easy it would be to use a single event handler, etc...

Jasconius