header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Inder
Points:3010
Posts:0

Optimize Flex SWF filesize performance loading
Posted On: 5/23/2009 4:56:34 AM

/ Views: 40564



Optimizing flex or Flash builder applications: So you are developing flex / Flash Builder applications and are worried by larger swf files generated by flex. Don’t worry its quite easy to reduce the file size of flex / Flash builder created swf's. I have identified out some major areas that can be focused to optimize the flex application size. These best techniques when followed in flex project will result in improved performance, smaller swf and less memory consumption.
Let’s discuss these six main areas to improve our flex(Flash builder) application:

  1. Implement RSL in your Project - Runtime Shared Libraries:- Its a flex framework library which contains files required during runtime of flex application. The advantage of RSL is that it’s downloaded once only. RSL simply reduces the file size by approximately 500kb. Implementing RSL is very easy :

    GOTO Project -> Properties -> Flex Build Path -> Library Path and select "Runtime Shared Library (RSL)" from the "Framework linkage" combobox.
    Press OK and you are done. Now application compiles and creates a framework (swz) file along with swf file looks like framework_3.2.0.3958.swz.

    Now you must copy this file to your webserver along with your swf file from where it can be downloaded.
    One most important thing is that you must have swz file extension added to your webserver. So that it can be accessed using url. Check that by using your website paths to framework if it can be saved to your disk then its fine else get it fixed first from you web administrator.

  2. Create SWC file of your common code:- If you are using some common classes that are used in many of your flex projects or different swf files then Create a Library Project of your commonly used classes. Now to add this library to your projects :
    GO to Project -> Properties -> Flex Build Path -> Library Path and Add folder containing swc file. Now your selected folder path starts appearing in "Build path Libraries".
    Remember to change the "link Type” to “Runtime Shared Library (RSL)". This file once downloaded will be used for all your swf files running on that Computer afterwards.

  3. Modules:- Create modules of components that are not required immediately or are optional for the application. And you can load them after some delay or later when required. This way you can reduce the file size and improve application performance.
    To create modules:
    • Create new module by going to File -> New -> MXML Module.
    • Add your code to the module file.
    • Add a ModuleLoader component into your main mxml where you want the component to appear and set the url property.

  4. Loading external content:- Do not embed content that’s not required immediately to be shown as application initializes Load assets at runtime. For example if you want to show a window containing thumbnails on user click , do not embed or load them on application initialize, just load them when user clicks to show that window .This way you will reduce size and improve performance of application.

  5. Optimize Flex (Flash builder) design and CSS:- Avoid adding heavy skins for components. Use vector designs for skinning. Images are bigger in size, difficult to render and distort on scaling so they should be avoided. Components can be given many effects and colors using style manager class. So for creating multi-color themes, its better to use dynamic styles rather than using multiple skins. For more info on setting color themes and changing effects check : Dynamic Style Sheet - theme flex. Split CSS into multiple files and load them at runtime according to requirement rather than embedding complete stylesheet .

  6. Using sub-applications:- By creating sub application related functionality can be encapsulated into a sub-application. Sub applications can be loaded using SWFLoader into any application. Sub applications are useful in case an functionality has to be shared across many applications. One major advantage is support for multi versioning. Multi-versioned applications can be compiled with version 3.2 of the Flex framework and later. For e.g. main application can be a Flex 4 application, and the loaded applications can be compiled with either version 3.2 or version 4 of the framework. Which means the sub application does not need compilation again and again.

To optimize flash applications check the following link:
Steps to optimise swf file size in flash, reduce swf size. How to


Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions