开发者

flash load multiple xml files

开发者 https://www.devze.com 2022-12-08 09:22 出处:网络
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 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 d开发者_Python百科o I know when all of the has been successfuly read and processed, to navigate futher.

please provide sample codes.


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.


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消