Jump to content
Search Community

onComplete firing before onChildComplete

rob_v_5712 test
Moderator Tag

Recommended Posts

Hello all,

I hope someone can help me out. I'm having a bit of an odd issue here.

I am loading SWFs into a container using an XML file of SWFLoader nodes.

 

After each node loads, Im checking to see if the swf meets certain criteria and set a flag.

 

Once everything is complete - I then proceed.

 

So I set up my loader and load it:

 

var slideListXmlLoader:XMLLoader = new XMLLoader("xml/slide_list.xml", { name: "data_xml", onComplete: slideListCompleteHandler, onChildComplete: slideListChildCompleteHandler});
slideListXmlLoader.load();

 

I have these set up for my handlers :

private function slideListChildCompleteHandler(e:LoaderEvent):void
{
trace('in slideListChildCompleteHandler');
.
.
.
do stuff here
.
.
.
trace('leaving slideListChildCompleteHandler');			
}

private function slideListCompleteHandler (e:LoaderEvent):void
{
trace('in slideListCompleteHandler');		
.
.
.
do stuff here
.
.
.
trace('leaving slideListCompleteHandler');			
}

 

The XML has 4 nodes in it. Given that - I would expect the trace to look like this :

 

in slideListChildCompleteHandler

leaving slideListChildCompleteHandler

in slideListChildCompleteHandler

leaving slideListChildCompleteHandler

in slideListChildCompleteHandler

leaving slideListChildCompleteHandler

in slideListChildCompleteHandler

leaving slideListChildCompleteHandler

in slideListCompleteHandler

leaving slideListCompleteHandler

 

But when I run it - it looks like this :

in slideListChildCompleteHandler

leaving slideListChildCompleteHandler

in slideListChildCompleteHandler

leaving slideListChildCompleteHandler

in slideListChildCompleteHandler

leaving slideListChildCompleteHandler

in slideListChildCompleteHandler

in slideListCompleteHandler

leaving slideListCompleteHandler

leaving slideListChildCompleteHandler

 

 

You can see for the last node - It hits the Child Complete Handler, then the main Complete handler, then leaves the main Complete handler, then leaves the Child Complete Handler.

I have a feeling its b/c of the processing that is in the slideListChildCompleteHandler that this occurs. Is there anyway to prevent this?

Link to comment
Share on other sites

Have you tried setting maxConnections:1 to see if it steps through nicer?

Also, check your xml for any errant typos or anything in that last node.

What does your xml look like?

Can't think of anything more with what you've provided so far...

 

Karl

Link to comment
Share on other sites

Yeah, this isn't sounding right to me either - I just tried a simple test that loosely copies what you're trying to do and it worked perfectly. The onChildComplete methods all got called BEFORE the XMLLoader's onComplete. So I'm really curious to see a sample FLA (and support files) that clearly demonstrates the behavior you're talking about. And are you 100% sure you're using the latest version of LoaderMax? Definitely update if you're not already on the latest version.

Link to comment
Share on other sites

Deleted the above 2 posts (included code snippets) figured it was better to just include a fla file that shows what Im talking about.

 

Pretty sure Im on the latest version of Greensock (just d/l them last week).

 

Here is a fla w/ supporting files that demos exactly what Im talking about.

If you run it as is - you will see what Im talking about in the trace - the main complete handler fires before all the children are complete.

If you change the slide_list.xml and put swf 4 in any other position - it works as you would expect - all the child completes fire then the main complete.

 

Please let me know if you see something different - or something that I am doing wrong.

 

Thanks

-Rob

Link to comment
Share on other sites

I see that you deleted your posts and then put new files up as I was typing my response to the previous post. So I deleted mine.

 

Okay, so now that I've looked at the example FLA (thanks for putting that together, by the way - VERY helpful), I can see what the issue is. You destroy() the child inside its onComplete. Consequently, that immediately removes it from the parent LoaderMax which then think to itself "okay, well now that my queue is empty of stuff that needs loading, I'm done! So fire my COMPLETE event." See the problem? It's a logic flow thing resulting from the way you structured your code. LoaderMax is behaving the way it should (at least from everything I can see it is).

 

The reason it worked when you changed the error-producing swf so that it wasn't last in the queue was because when it was destroyed, the parent LoaderMax still had another child in its queue left to load, so it didn't fire its COMPLETE event.

 

Make sense?

 

So either write your code such that it accommodates the LoaderMax completing immediately when you destroy() its last child or delay the destruction of that child until later. My vote would be for the former, not the latter.

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