Header image

AS3 Preloading continued

November 30th, 2007 | Posted by lars in Actionscript

I wasn’t really satisfied with the solution I used for my AS3 preloader (see post: Preloader in AS3 projects). Now Sven found THE solution. It’s in german, so I try to explain how it works:

The class “Test” acts as the factory class that’s responsible for the preloading. The Class “Demo” is the main application class. Using the compiler option -frame frameLabel Demo, the class Demo is compiled into frame 2.

Just like in Keith Peter’s Example and my try using an exclude xml, you can preload a pure AS3 application now, but in this case no flex framework classes are compiled into the resulting SWF and there is no need for an exclude xml. Finally!

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

11 Responses

  • sectore says:

    Nice discussion and thanks to Sven for sharing his solution.

    Anyway, I prefer Keith’s way and hide all Flex classes located within
    the “mx” packages folder using an individual config file named
    “Application-config.xml” and add this as a compiler option


    or using Adobes Flex Ant tasks
    <load-config filename=”${basedir}/Application-config.xml” />

    To avoid to include the Flex classes mentioned above I declare within
    the “Application-config.xml” only the “playerglobal.swc” as a element of
    the library path:


    Anyway, that’s not the only way of doing and Sven’s solution is pretty
    straight forward , too ;-)



  • guntur says:

    Hi, what flex version are you using with the -frame option? I have flex2SDK and it won’t work. The [Frame(factoryClass="")] embed works great though. Thanks

  • lars says:

    I’m using the Flex 3 SDK, but the frame option does exist in Flex 2 as well.

  • ragaskar says:

    this seems to work fantastically when compiled from Flex Builder and viewed with FF, but not at all when I serve it from our web server (and view with FF or IE) or view it with IE7 (web or locally).

    You don’t have any live examples up so I can see if it’s something with my code or a common problem? Trying to eliminate some of the mystery variables.

  • ragaskar says:

    holy smoly. I uploaded it to another server (which happened to be running lighttp/debian), and it worked great on both IE (which STILL isn’t ‘testing’ properly locally) and FF.

    so obviously there is something going on with my other server (Apache/CentOS). wonder if it’s a mime type deal or because of APC or something.

    this is going to drive me nuts.

    although hey, I guess I didn’t REALLY need to have gotten any coding done for the last 5 hours.

  • ragaskar says:

    Problem solved: Apache was gzipping my flash file, which (I’m assuming) forced the browser to download the entire file before it was able to display it.

    Weirdly enough i was unable to find any gzip config beyond the simple loading of the delate module — everything was gzipping regardless. Anyhow, was able to turn off deflate/gzip from htaccess using someone else’s gzip config (be warned this probably also ADDS gzip on some items in addition to turning it off for swfs):

    SetOutputFilter DEFLATE
    # Netscape 4.x has some problems…
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
    # the above regex won’t work. You can use the following
    # workaround to get the desired effect:
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    # Don’t compress images
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \/image\.php no-gzip dont-vary
    # Also don’t compress PDF and Flash-files 17-01-2004 MM
    SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.swf$ no-gzip dont-vary
    # Make sure proxies don’t deliver the wrong content
    Header append Vary User-Agent env=!dont-vary

  • Pingback: Writing a preloader in ActionScript 3 | Jetpack Development

  • I think your right that the -frame compiler option is a simple way of doing things. I’ve written a preloader using this method that combines this with MochiAds, MochiBot, Glossy Progress Bar and Simple domain locking – and i’ve put the source code up on my blog http://www.adventuresinactionscript.com/ if anyone wants it and i’ve linked you as the source where i found the info – so cheers for finding and the explanation!

  • Pingback: Flex常用网站 « XuYin's Blog!

  • Pingback: xuyin's blog | Flex常用网站

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">