Jump to content
Search Community

get the whole progress

paulr test
Moderator Tag

Recommended Posts

what i want to do is to load a xml file and a main.swf. in the xml file are other swf files defined that i need in the main.swf. I have define a xmlLoader a swfLoader and a loaderMax. Then i prepend the xmlLoader and append the swfLoader with the defined oncomplete handler in the xmlLoader i set a variable completeXml to capture in the oncomplete swf handler when i can set the xml data to the swf. or is in this case (the main.swf needs the xml data) the requireWithRoot variable useful? the other question i have is: i don't see a way to get the moment there are all swf's from the xml file loaded. i don't found a handler like oncomplete for the loadermax. Or have to pass the number of child swfs in the xml and work with a counter in the onChildComplete handler?

thanks for help mith my struggles

Link to comment
Share on other sites

Sure, this should be relatively simple. Keep in mind that XMLLoader AUTOMATICALLY integrates any loaders that are defined inside the XML into its own progress (well, any that have a load="true" attribute). So its onComplete won't fire until those loaders are done. For example, of the XML file looks like this:

 



 

When you load this XML with an XMLLoader, that XMLLoader will automatically recognize the LoaderMax and SWFLoaders defined therein and load them for you (notice I set load="true" on the LoaderMax). The XMLLoader will dispatch its COMPLETE event only AFTER both swfs have been loaded.

 

Also, if you want to know when the entire LoaderMax queue has completed, just listen for the LoaderMax's COMPLETE event (or use the simple onComplete special property to have it set up the listener for you). And if you want the LoaderMax queue to load sequentially, only allowing one at a time so that the XML loads first, then the swf, you can set the maxConnections to 1 (not that you need to). There are all sorts of conveniences in there like this. So your code could look like:

 

var queue:LoaderMax = new LoaderMax({maxConnections:1, onComplete:queueComplete});
queue.append( new XMLLoader("data.xml", {name:"xmlData"}) );
queue.append( new SWFLoader("file3.swf", {name:"swf3"}) );
queue.load();

function queueComplete(event:LoaderEvent):void {
   var swf1:DisplayObject = LoaderMax.getLoader("swf1").rawContent; //from inside the XML!
   var swf2:DisplayObject = LoaderMax.getLoader("swf2").rawContent; //from inside the XML!
   var swf3:DisplayObject = LoaderMax.getLoader("swf3").rawContent; 
   //your code here...
}

 

Does that answer your questions?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...