Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
fed

Problem with LoaderMax.getChildIndex

Recommended Posts

This is essentially what is happening to me:


var _queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});
_queue.append( new XMLLoader("test.xml", {name:"test",noCache:true, estimatedBytes:"22000", onComplete:xmlCompleteHandler, onFail: xmlFailHandler}));	
_queue.load();

var currentSwfLoader:LoaderCore = _queue.getLoader(String(path));     //path is the url for the SWFLoader
if (currentSwfLoader) {
    var index:uint = _queue.getChildIndex(LoaderCore(currentSwfLoader));
    trace(index);  //it is 999999999

    var nextSwfLoader:SWFLoader = _queue[index];
}

 

So the trace returns 999999999. Clearly the LoaderCore object isn't being found in the LoaderMax object even though I pull it directly from the LoaderMax object and determine that it exists (I have also traced it out).

 

I need to get the SWFLoaders immediately following currentSwfLoader and so I am trying to get the index and then bump it up to get the next few. Will that work? Is there a better way? There seems to be no way to get a LoaderCore based on an index :( Either way getChildIndex isn't seeming to work.

 

Thanks for your help!

Link to comment
Share on other sites

What does "path" refer to? Are you sure the getLoader() is finding the loader? Is "path" the same as "test.xml"? It's very difficult to tell based on the code you posted.

Link to comment
Share on other sites

Sorry, the path is the url for the SWFLoader.

 

The returned object for getLoader() is not null and it traces out as where both the name and the url are as expected, so I think it is getting the SWFLoader.

Link to comment
Share on other sites

Please post an example FLA that demonstrates the issue - I have triple-checked and getChildIndex() works perfectly for me and the ONLY time it will return 99999999 is when the loader cannot be found, so either you're passing a null loader or you're passing it a loader that is NOT a child of that particular LoaderMax instance.

Link to comment
Share on other sites

Well is there any way to numerically index into the LoaderMax queue? If not then I'm not traveling down a productive road anyway :D

Link to comment
Share on other sites

Well is there any way to numerically index into the LoaderMax queue?

 

What exactly do you mean? You can certainly insert() loaders at a particular index (although if you define an index that's greater than the number of children, the index will be adjusted down automatically) and you can getChildIndex() to find out what index a particular loader has in the LoaderMax instance's queue. Does that answer your question?

Link to comment
Share on other sites

Well is there any way to numerically index into the LoaderMax queue?

 

What exactly do you mean? You can certainly insert() loaders at a particular index (although if you define an index that's greater than the number of children, the index will be adjusted down automatically) and you can getChildIndex() to find out what index a particular loader has in the LoaderMax instance's queue. Does that answer your question?

 

Say I want the loader at position n, is there any way to get it if I have only 'n' and the queue? I haven't seen any obvious way...

Link to comment
Share on other sites

Oh. Sure. That's what getChildren() is for.

 

var loaders:Array = myLoaderMax.getChildren();
trace("the loader at index 2 is: " + loaders[2]);

Link to comment
Share on other sites

Oh. Sure. That's what getChildren() is for.

 

var loaders:Array = myLoaderMax.getChildren();
trace("the loader at index 2 is: " + loaders[2]);

 

Oh okay, thanks!

 

I figured it out. There was a nesting problem. For some reason the top level contained an XMLLoader and nothing else, which then contained all of the SWFLoaders.

 

Thanks for your help!

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