PDA

View Full Version : Loader events


astgtciv
08-06-2006, 02:08 AM
flash.display.Loader fires complete and init events, and I find this explanation from the Loader AS3Langref (http://livedocs.macromedia.com/labs/as3preview/langref/flash/display/Loader.html) very confusing:


The complete event is dispatched when a file completes downloading, but before the loaded movie clip's methods and properties are available.
The init event is dispatched after the properties and methods of the loaded SWF file are accessible, so you can begin manipulating the loaded SWF file. This event is dispatched before the complete handler. In streaming SWF files, the init event can occur significantly earlier than the complete event. For most purposes, use the init handler.

Would someone care to clarify? E.g., what is the subtle difference between "available" and "accessible"?

diogo
08-06-2006, 04:31 AM
Have you tested these events? I've made a simple test and both events can access properties and methods from movieclips located in the loaded SWF.

What I understand of the quote from AS3Langref is that with the init event you are able to know when the content is loaded, but you can't access its movieclips' properties and methods, while with the complete event you also know when the content is loaded, and you can access the movieclips located inside the loaded SWF.

I just don't understand why the init event is invoked before the complete if it can access properties and methods that the complete event can not. (that's what the documentation says, but in my tests, as I said, both events have had similar results)

Tink
08-06-2006, 10:54 AM
What I understand of the quote from AS3Langref is that with the init event you are able to know when the content is loaded, but you can't access its movieclips' properties and methods, while with the complete event you also know when the content is loaded, and you can access the movieclips located inside the loaded SWF.

I just don't understand why the init event is invoked before the complete if it can access properties and methods that the complete event can not. (that's what the documentation says, but in my tests, as I said, both events have had similar results)your contradicting yourself there??

complete - content has loaded.
init - the loaded content had initiated and its props and methods are available.

As you mentioned u can sometimes access props and methods if the object u load is simple. I would advise using the init event to make sure.

Incrue
08-06-2006, 12:47 PM
Thats really a contradiction, first
init event you are able to know when the content is loaded, but you can't access its movieclips' properties and methods
and later
why the init event is invoked before the complete if it can access properties and methods that the complete event can not.

astgtciv
08-06-2006, 03:39 PM
I guess it's not only confusing to me :D

diogo
08-06-2006, 04:13 PM
hoho sorry, my bad :)
it was 4:30 am here when I wrote that (actually that's not a reason for a too big mistake :) )

So it's like Tink said:

complete - content has loaded.
init - the loaded content had initiated and its props and methods are available.

if the init event can access what the complete event can't, why it's invoked before the complete event?

Yes, that's really confusing :P

Tink
08-07-2006, 10:24 AM
if the init event can access what the complete event can't, why it's invoked before the complete event?it shouldn't be. i've not tested it, but i think you'll only get those results when loadng simple objects.

This really has the same events as MovieClipLoader is AS 2.0.