Skip to main content
April 13, 2013
Answered

Check if Load Multiple XML file Complete. How ?!

  • April 13, 2013
  • 1 reply
  • 696 views

Hello,

I want to create loading screen and i want to check if all my XML file ( class10.xml, class11a.xml & class11s.xml ) finish loading go to frame 2. How can i do that ?!

Regards,

This topic has been closed for replies.
Correct answer Ned Murphy

if you assign COMPLETE event listeners to the loaders, you can keep a count of how many have completed loading and use that to trigger going to frame 2

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
April 13, 2013

if you assign COMPLETE event listeners to the loaders, you can keep a count of how many have completed loading and use that to trigger going to frame 2

April 13, 2013

Thanks for the tip, So there no  class in as3 to load multiple file and check if all of them complete...?!

Inspiring
April 13, 2013

No there are no core class doing that but it's quite easy to do it sequentially or to create a simple class that does that. That could go something like that:

1. pass an array of paths to your custom loader class:

var loader:MultipleLoader = new MultipleLoader(["path1.xml", "path2.xml"])

loader.addEventListener(Event.COMPLETE, moveOn);

loader.load();

Then in your MultipleLoader class you can do:

public function load():void

{

     loadNextXML();

}

private function loadNextXML(e:Event = null):void

{

     if(!myxmlarray.length)

     {

          dispatchEvent(e);

          return;

     }

     var path:String = myxmlarray.shift();

     //code to load each xml from the array that was passed and stored in myxmlarray Array

     //you register Event.COMPLETE with loadNextXML method so you can cycle until the array is empty

}