Jump to content
Search Community

Branch after x of y loaders (SWFLoaders) have completed?

BGoulette test
Moderator Tag

Recommended Posts

Hi all,

 

I'm sorry to clog up the forums with something I'm sure I should be able to figure out, but I'm stuck.

 

I have an arbitrary number of SWFs all loaded into a "shell" swf via LoaderMax. These swfs are pulled from references in an XML file (though that shouldn't matter). I have a "loading" progress bar that currently waits until everything (SelfLoader, XMLLoader, and all the SWFLoaders) is finished before displaying the first loaded SWF.

 

Let's say there are 7 SWFs. After the second is fully loaded -- and these have been prioritized, so hopefully that will help keep things in order -- I want to display the first loaded SWF while the remaining 5 load in the background.

 

I have my handlers set up so that I can detect when the desired number of SWFs have been loaded (2 is also arbitrary and user-definable), but after that, I'm not sure how to tell my "shell" to display the first loaded SWF.

 

Any suggestions? Thanks!

Link to comment
Share on other sites

Thanks, Carl, but that's not quite what I meant.

 

I can load and display everything as necessary -- once all the SWFs have been loaded. What I need to do is find some way to trigger the "onComplete" handler prematurely while still loading the remaining SWFs...

Link to comment
Share on other sites

To tell the the second SWFLoader to use the same completeHandler function as your LoaderMax:

 

secondSWFLoader.addEventListener(LoaderEvent.COMPLETE, completeHandler)

 

if you are already detecting when the second swf is loaded you should be able to just call the completeHandler yourself. Just make sure that it doesn't need to accept a LoaderEvent.

 

function onComplete(e:LoaderEvent = null):void{
//do stuff
}

 

Not really getting why the LoaderMax would have an onComplete handler assigned that is supposed to run before all the assets are loaded but the above suggestions should work.

Link to comment
Share on other sites

Thanks again, Carl. Yeah, it's an odd thing, but it's building on older code that, once upon a time, did require everything to be loaded, hence the original onComplete for the entire LoaderMax instance versus its children.

 

That said, I've been poking around, and I think adding an onChildComplete listener to my primary LoaderMax instance ($loader, in this case) will help. It seems to be, but now I just need to make sure the other two loaders, SelfLoader and XMLLoader have finished and have been handled before prematurely calling my completeHandler.

 

It's a big steamy mess, but I think I'm on the way to getting it to behave properly! :)

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