How should I optimize my Flash file?

Discussion in 'Web Design and Development' started by chiefroastbeef, Dec 5, 2008.

  1. chiefroastbeef macrumors 6502a

    Joined:
    May 26, 2008
    Location:
    Dallas, Texas/ Hong Kong
    #1
    Hello all,

    I currently have a flash file that is 2.3mb. The file is just comprised of a couple images, with a paragraph at the end of the movie, lasting around 17 seconds.

    I've tried flash optimizer, the free trial version. It works great, but it'll only save the file in black and white, and I much rather have it in the original colors. I am unwilling to pay $99 for the program that I know I will not use much.

    Is there another way of optimizing a flash file? Or should I just redo the whole thing using optimized images? If so, do i just optimize with fireworks(which I have)?

    Thanks for the advice!

    chief
     
  2. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #2
    hhmm im not sure about this, but can you do a "Export" on the flash file and possibly downgrade the quality of the file??
     
  3. chiefroastbeef thread starter macrumors 6502a

    Joined:
    May 26, 2008
    Location:
    Dallas, Texas/ Hong Kong
    #3
    That is a good idea, let me check. But perhaps later, I need to go to the bathroom.

    *number two*
     
  4. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #4
    lol pretty sure i didnt need to know that, but whatever haha
     
  5. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #5
    Yeah, TOO MUCH INFORMATION.

    Of course, attention to detail is a good thing, usually.

    Now, about that Flash stuff...

    Did you try THIS freeware Flash optimizer?

    Also, the images themselves could (and should) be optimized before being inserted as objects within Flash. Adobe PhotoShop -> Save for Web and save as a JPG and optimized accordingly, for example, or use one of the online optimizers like this one. Optimizing reduces redundant pixels, uses the least amount of colors in the best possible palette (bits) which reduces file size. You mentioned the images stuff in your post so I suspect they're not small and might factor in to overall .swf filesize.

    -jim
     
  6. snickelfritz macrumors 65816

    snickelfritz

    Joined:
    Oct 24, 2003
    Location:
    Tucson AZ
    #6
    • code your project in Actionscript 3.0 if at all possible.
      you can expect up to a 10x improvement in performance from this factor alone.
    • complex vector graphics that are not transformed at runtime can be cached as bitmaps.
      object translations, such as changing the xy coordinates are fine.
      Code:
      circle.cacheAsBitmap = true;
    • eliminate transparency masks whenever practical, by setting the background of objects to opaque.
      This reduces the vector information to a simple rectangular bounding box.
      This is especially valuable with complex vector graphics such as logos.
      For example, a movieclip that contains a circlular shape, instance name "circle" will, by default, include a circular transparency mask.
      If the site background is a solid color, 0x0066FF, for example, you can set the background for the circle movieclip to the same value.
      Code:
      circle.cacheAsBitmap = true;
      circle.opaqueBackground = 0x0066FF;
    • load external assets dynamically instead of embedding everything into a single SWF.
      this reduces the initial loading time for the site, in some cases dramatically.
    • remove event listeners and references to objects when they are no longer needed.
      this mitigates the potential for memory leaks, and reduces overall memory overhead.
    • use multiplication instead of division in your actionscripts; it usually executes faster.
    • use strict datatyped variables and arrays to store objects and properties.
    • use "int" for numbers whenever practical; it's slightly faster than "Number" and significantly faster than "uint".
    • oversized SWF files will tend to run slowly.
      it's analogous to video games; 1600x1200 will always have a lower framerate than 800x600.
     
  7. chiefroastbeef thread starter macrumors 6502a

    Joined:
    May 26, 2008
    Location:
    Dallas, Texas/ Hong Kong
    #7
    Thank you all for the suggestions above! I will do it over again(it doesn't take too long) with the what you guys have suggested.

    The flash optimizer program is great, however, the free trial only saves the optimized file in black and white, not with the original colors.

    Thanks again guys! This is great stuff!
     
  8. chiefroastbeef thread starter macrumors 6502a

    Joined:
    May 26, 2008
    Location:
    Dallas, Texas/ Hong Kong
    #8
    Guys,

    I cropped my pictures to size in Fireworks, then swapped them with the original pictures in the .fla. Went from 2.3mb to 545k!

    Thanks again, you guys are just too good!
     
  9. snickelfritz macrumors 65816

    snickelfritz

    Joined:
    Oct 24, 2003
    Location:
    Tucson AZ
    #9
    It's customary to include a progress indicator for large SWF files.
    (500K is a relatively large SWF)

    A good way to do this is to create a parent SWF that has nothing in it but an empty loader object connected to a simple preloader script, and a progress indicator on the stage; your main content SWF is loaded into this loader object from an external directory on the server.
    The external SWF files could also have their own loader objects and scripts as well.
    You could literally have dozens or even hundreds of content SWFs stored on the server without the download/memory/stability problems associated with bloated single SWF solutions.

    This is an ideal way to construct Flash applications for distribution over the internet, since the speed of the client internet connection becomes less of a factor in terms of delivering a large amount of content spread across several sections of a Flash website.
    Imagine a single SWF file that has dozenss of images embedded in a gallery, an interface, a contact form, and several text pages; the filesize would quickly become far too large for practical internet delivery, and the FLA would be a nightmare to edit.

    Here's an example script that fades-in a progress indicator, which runs until the file is fully loaded, then fades-out the progress indicator, then fades-in the loaded content.
    Paste the script into frame1 of a new FLA with the same dimensions as your main SWF.
    (named "main.swf" in this example)
    The TweenLite class is used here for smooth alpha transitions for the preloader and loaded SWF.
    Download the TweenGroup class and place the gs directory in the directory as your FLA. (the download includes, TweenLite, TweenGroup, TweenMax, some useful utilities, and some good easing classes)

    The progress indicator is an empty Dynamic TextField with fonts embedded, wrapped in a MovieClip on the stage: "preloader.preloadText"
    Compile the loader.swf and embed it in your HTML page.

    PHP:
    import gs.*;
    import gs.easing.*;

    /*---------------------------------------------------------------------------------*/

    TweenLite.to(preloader0, {autoAlpha:0});
    var 
    mainLoader:Loader = new Loader();
    mainLoader.0;
    mainLoader.0;
    mainLoader.contentLoaderInfo.addEventListener(Event.COMPLETEonLoaded);
    mainLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESSonProgress);
    mainLoader.load(new URLRequest("main.swf"));// this loads your content SWF

    /*---------------------------------------------------------------------------------*/

    function onProgress(e:ProgressEvent):void
    {
        
    TweenLite.to(preloader.4, {autoAlpha:1});
        var 
    percentage:Number e.bytesLoaded e.bytesTotal;
        
    preloader.preloadText.text Math.ceil(percentage 100).toString() + "%";
    }
    /*---------------------------------------------------------------------------------*/

    function onLoaded(e:Event):void
    {
        
    TweenLite.to(preloader.2, {autoAlpha:0onComplete:loadMain});
    }
    /*---------------------------------------------------------------------------------*/

    function loadMain():void
    {
        
    removeChild(preloader);
        
    preloader null;
        
    addChild(mainLoader);
        
    TweenLite.from(mainLoader.2, {alpha:0});
    }
    /*---------------------------------------------------------------------------------*/
     
  10. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #10
    Great advice. As a user, I appreciate it when developers add that - it's not only professional looking, but I don't sit there wondering if the site bombed, so a progress indicator is the way to go. And don't forget add a way to "skip" any Flash Intro which is optional viewing.

    -jim
     
  11. chiefroastbeef thread starter macrumors 6502a

    Joined:
    May 26, 2008
    Location:
    Dallas, Texas/ Hong Kong
    #11
    Thank you for that wondrous tip! I will dl the program and embed it in.

    here is the site I am working on in progress: http://inprocess.ca/sam

    most of the links work, some don't because I haven't gotten to it yet. Let me know your suggestions should you guys have time!

    Sam
     
  12. DesignEmbrace macrumors newbie

    Joined:
    Dec 8, 2008
    #12
    I like the website alot. Good color scheme. Pretty simple and easy to use. I like it.
     

Share This Page