Adobe Flex 3 Help

Optimizing RSL SWF files

The default SWF file in your SWC files includes debugging code and metadata that increase the file size. The debugging code is necessary for the compiler to run, but is not necessary at run time unless you want to debug the RSL. You can remove the debug code and unnecessary metadata by using the optimizer tool.

If you use the optimizer tool, you must keep track of two separate library files: one for compiling (the larger, pre-optimized one) and one for deploying (the smaller one, optimized one). You compile your main application against the non-optimized library but then deploy the optimized library so that it can be loaded at run time.

The optimizer tool is in the bin directory. For Unix and Mac OS, it is a shell script called optimizer. For Windows, it is optimizer.exe. You invoke it only from the command line. The Java settings are managed by the jvm.config file in the bin directory.

The syntax for the optimizer tool is as follows:

optimizer -keep-as3-metadata="Bindable,Managed,ChangeEvent,
NonCommittingChangeEvent,Transient" -input input_swf -output output_swf

You must specify the keep-as3-metadata option and pass it the required metadata. At a minimum, you should specify the Bindable, Managed, ChangeEvent, NonCommittingChangeEvent, and Transient metadata names. You can also specify custom metadata that you want to remain in the optimized SWF file.

You can specify the configuration file that the optimizer tool uses by using the load-config option.

To get help while using the optimizer tool, enter the -help option:

c:\flex\bin> optimizer -help

By default, the optimizer tool saves an optimized version of the SWF file in the current directory, with the name output.swf. This file should be smaller than the library.swf because it does not contain the debugging code.

Use optimized RSLs

  1. Create an RSL by compiling a library project in Flex Builder or building a SWC file with the compc command line tool.
  2. Compile your main application and reference the RSL.
  3. Extract the library.swf file from your RSL's SWC file, if you haven't done so already.
  4. Run the optimizer against the library.swf file, for example:
    c:\bin> optimimzer -keep-as3-metadata="Bindable,Managed,ChangeEvent,
    NonCommittingChangeEvent,Transient" -input c:\rsls\library.swf -output c:\rsls\output\output.swf
  5. Deploy the optimized library (in this case, output.swf) with the application so that the application uses it at run time.