Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-29-2007, 01:35 AM   #31
dcster2001
Member
 
Join Date: Nov 2007
Posts: 86
Default

The main assets start loading in frame one, that's true, but the movie will display once the first frame content is loaded (you can do this with the Event.INIT listener in a document class .as file as well). The key is having the preloader assets small enough so that the initial display of the movie isn't delayed significantly while the first frame loads... The preloader takes care of the rest.

I am wondering whether the export actually loads the assets or simply starts the loading of the assets. I know that an asset isn't available until it is actually present on the stage. Moock's description of the file states that "the assets are loaded on frame 15."

Last edited by dcster2001; 11-29-2007 at 01:39 AM.
dcster2001 is offline   Reply With Quote
Old 11-29-2007, 01:53 AM   #32
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

This is a screenshot of the first frame of the preloader you attached when a real asset is added. I simply added a pic instead of a blue book. You can see it all exports on frame 1.
Attached Thumbnails
Click image for larger version

Name:	image copy.jpg
Views:	216
Size:	134.9 KB
ID:	24970  
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 11-29-2007, 02:23 AM   #33
dcster2001
Member
 
Join Date: Nov 2007
Posts: 86
Default

Okay, I think I'm getting it now. Again, from Moock's Essential ActionScript 3.0 (the sky.fla is the example code I modelled the test3.fla after):

Quote:
Preloading Classes
By default, when the Flash authoring tool compiles a .swf file, it exports all classes in the .swf file's first frame. As a result, all classes used in the .swf file must finish loading before the .swf file's first frame is displayed. Depending on the the total file size of the classes included in the .swf file, this loading process can result in a noticable delay before the .swf file begins to play.

To avoid the class-loading delay, we can export a .swf file's classes after Frame 1 in the main timeline, and then provide a simple timeline script that displays progress information during the class-loading process.

As an example, let's change our sky.fla file so that the classes is uses aren't loaded until frame 15. Note, however, that a .swf file's document class-- and evey class the document class references, whether directly or indirectly-- always loads in Frame 1. Hence, to prevent the Star class from loading before Frame 1, we must first remove the instance names from all manually created Star instances and we will delete the definitions for the variables star1 through star5 from the Star class code. To remove the instance names, we select each Star instance on Stage and delete its name from the properties panel.

The following procedures describe how to load sky.fla's classes at Frame 15:

1. Open the sky.fla in the Flash authoring tool.
2. Choose File -> Publish Settings.
3. In the Publish Settings dialog box, on the Flash tab, next to ActionScript Version:Version 3.0, click Settings.
4. In the ActionScript Settings dialog, for Export Classes in Frame, enter 15.
5. Click OK to confirm the ActionScript Settings.
6. Click OK to confirm the Publish settings.

Next, we add a very basic timeline preloader to sky.fla so that a "Loading" message appears while the classes load...

(Preloader code omitted)

... That's it!
So it is the .swf Publish Settings that controls when classes load, not the individual linkage properties of the class itself that determines when the class is actually loaded. In fact, I can't figure out what the class linkage "Export in Frame 1" actually does, except that you seem to have to check it, since the class will not display unless it is set to export at Frame 1.

So I think the question is answered, and the problem solved as far as I can tell, unless Moock is all wet.

Last edited by dcster2001; 11-29-2007 at 02:27 AM. Reason: Correct typo
dcster2001 is offline   Reply With Quote
Old 11-29-2007, 02:38 AM   #34
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

Quote:
Note, however, that a .swf file's document class-- and evey class the document class references, whether directly or indirectly-- always loads in Frame 1.
That's the answer, like I even mentioned back in post #21, but it doesn't fix the issue. These classes cause a noticable delay! A true single file .swf preloader is imposssible.


However, this still leaves the issue in the air as to what was happening in the orginal file that I posted where the graphics are never shown.
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");

Last edited by Flash Gordon; 11-29-2007 at 02:40 AM.
Flash Gordon is offline   Reply With Quote
Old 11-29-2007, 02:53 AM   #35
dcster2001
Member
 
Join Date: Nov 2007
Posts: 86
Default

Nice pic, Flash! That's quite a loaded asset!

I am not familiar with the debugger, but doesn't it say that you are on frame 15 (status: frame 15)? Given the code, it would be impossible for the asset to be displayed on frame 1, since there's no code to allow it-- it's all blank frames, except for the preloader dialog.

Again, sorry if my ignorance of the debugger is misinterpreting the data you presented. Could it also be possible that the loading process itself is completed on Frame 1 because the file size is so small.

The preloader is polling the ongoing load operation of the swf that begins on frame 1, but with a 15 frame buffer to allow the movie to load faster. Thus, the loading process begins immediately for the rest of the classes, but the INIT event allows the movie to display frame 1 as soon as it's available. I think I'm now getting the logic of the whole thing:

It wouldn't make sense for a swf not to start the loading process immediately. If that were true, the movie would never get to frame 15, because the loading process would never start and the preloader would loop forever. The Publish Settings "Load Classes" statement allows the movie enough space to create a preloader and display the movie immediately, without waiting for the other loaded assets to load first. Therefore, you have to specify "Export in Frame 1" in your classes' linkage dialog for the preloader to work as intended. Otherwise, you'd have nothing loading until then, defeating the purpose of the preloader and causing an endless loop.

It would be nice if there were an explanation of these nuances somewhere, but again, I don't think Colin Moock would get something like this wrong...
dcster2001 is offline   Reply With Quote
Old 11-29-2007, 03:01 AM   #36
dcster2001
Member
 
Join Date: Nov 2007
Posts: 86
Default

Quote:
That's the answer, like I even mentioned back in post #21, but it doesn't fix the issue. These classes cause a noticable delay! A true single file .swf preloader is imposssible.
Actually test3.fla doesn't have a document class per se (one is created when the fla is published, but you didn't write a document class .as file controlling the start of the movie, which is what Moock is referring to here).

Are you sure the code in your real movie doesn't invoke a lot of assets in its document class .as file or on the first frame of the fla?
dcster2001 is offline   Reply With Quote
Old 11-29-2007, 04:25 AM   #37
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

Don't worry about it. Unless someone can show me an example of how to preload an OOP swf without have all classes exported in frame 1, this thread won't be solved. And since it isn't possible.....

Anyway, thanks everyone for the input.
Cheers
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 11-29-2007, 10:36 AM   #38
creynders
flash veteran
 
creynders's Avatar
 
Join Date: May 2005
Location: Belgium
Posts: 914
Default Solved...

Bad news for you flash gordon...
Look at the zip and you'll find it does exactly what you want. It's ugly and hackish, but it does the job.
Now, hand over that cash

First have a look at it and then I'll give you some explanation if you want.

--EDIT: Minor mistake: fixed--
Attached Files
File Type: zip export.zip (7.2 KB, 222 views)

Last edited by creynders; 11-29-2007 at 10:59 AM.
creynders is offline   Reply With Quote
Old 11-29-2007, 11:13 AM   #39
creynders
flash veteran
 
creynders's Avatar
 
Join Date: May 2005
Location: Belgium
Posts: 914
Default

I won't have time to explain it later on, so I'll do it at once.

The flow is as follows:
The document class of the fla file is FilePreloader.
It gets instantiated, waits to load the full swf file (here's where the progressbar would come if you want to use one)
Then it starts playing and checks whether the playhead has passed the frame where the other classes have been exported to.
If that is the case it instantiates the "Application" class, which is like your main class. Which in turn instantiates the Box class (which has a graphic in it, to test whether my solution is "real" put a 2Mb picture in box and you'll see it's correct)

The EmbedClasses class and Lib symbol is needed, you have to put ALL classes and libsymbols you want to have exported in this symbol and put it on the main timeline on the frame where you defined your classes to be exported to.

You'll notice an "Application" symbol in the library as well (with nothing in it). This may seem useless, but it's necessary because you HAVE TO add it to the EmbedClasses symbol.


BTW, what led me to this solution is this article:
http://kb.adobe.com/selfservice/view...1348&sliceId=1
creynders is offline   Reply With Quote
Old 11-29-2007, 04:35 PM   #40
dcster2001
Member
 
Join Date: Nov 2007
Posts: 86
Default

Well I finally loaded the test3.swf to my website and tested it with a 2MB pic attached to Box. You are correct, Flash_Gordon, there is serious lag before the dang thing displays. I am a bit pissed with Moock on this one. His preloader really doesn't work as he purports-- and I don't even know of a way to let him know about it-- grrrrr.

Also, the link provided by creynders seems to suggest that the display bug was fixed, but there's no way to get it to display the dynamic Box instance unless either the .swf Publish Settings is set to load classes on Frame 1 or the linkage settings for Box export on Frame 1, either of which defeat the purpose of the preloader.

This is sort of basic to me-- why would something like this get overlooked by the developers? I assume from all this that the Event.INIT listener really doesn't display just the Frame 1 content until all the other classes are loaded as well... this sucks.
dcster2001 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shared Libraries and Exporting for Actionscript jenigrant ActionScript 2.0 3 11-29-2006 01:07 PM
Preloading and frame exporting of assets and classes FFighter ActionScript 2.0 3 04-05-2006 02:07 AM


All times are GMT. The time now is 11:22 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.