nulldesign // lars gerckens » AS3 Preloading continued

AS3 Preloading continued

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!

30. November 2007 | Posted in Actionscript

9 Comments

  • 1. sectore  |  17. December 2007 at 21:30

    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

    -load-config={pathToYourProject}/Application-config.xml

    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:

    <library-path>
    <path-element>{pathToFlex2SDK}/frameworks/libs/playerglobal.swc</path-element>
    </library-path>

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

    -sectore

    http://www.websector.de/blog/

  • 2. guntur  |  14. January 2008 at 09:12

    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

  • 3. lars  |  14. January 2008 at 11:33

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

  • 4. ragaskar  |  14. March 2008 at 02:27

    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.

  • 5. ragaskar  |  14. March 2008 at 04:07

    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.

  • 6. ragaskar  |  14. March 2008 at 19:00

    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

  • 7. Writing a preloader in Ac&hellip  |  25. March 2008 at 16:49

    [...] for discovering this (unfortunately the text is German, but the source code is readable). Also thanks to Lars Gerckens for his research, and BIT-101 for this alternate solution. And of course thanks to Adobe for [...]

  • 8. TheActionscriptMan  |  04. April 2008 at 02:07

    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!

  • 9. Ponce  |  13. July 2008 at 02:21

    Very Nice !

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Trackback this post  |  Subscribe to the comments via RSS Feed

About

  • nulldesign is the company and showcase site of freelance developer Lars Gerckens who is based in Hamburg, Germany. I'm available for freelance work with focus on Flex, Flash and AIR development. I like to create dynamic user interfaces, cutting edge web experiences and innovative ways to visualize data.

    This site showcases some of my personal work and projects as well as an selection of commercial projects.

    If you are interested in my work or you have any questions, don't hesitate to drop me a line:

  • Profiles: Xing | Linkedin
  • Mail: lars [at] nulldesign [dot] de

Categories

Search