Optimizing the SWF filesize for your Flex App

While wandering through the ginormous forest that is Flex I’ve noticed how the filesize grows exponentially when you start to add a lot of content, or some external libraries. This is annoying, especially when the app I’m making is supposed to be used by a large group of people at the company I work for. So, I went looking for ways to slim it down, and I have found a couple of gems that work really well. First of all there is an excellent video posted by Serge Jespers of the Adobe Platform Evangelism – European team that gives some detailed tips with an example of how to make your application smaller with Flex Builder.

Namely:

  1. Use “Release” build — by default the SWF is built with Debug mode and has debug & profiler code in it that your application doesn’t need.
  2. Move your panels into modules(see movie)
  3. Use the RSLs instead of compiling the Flex framework into your SWF

Using these suggestions has removed over 500K from my app.

The video shows you how to do all of these in Flex Builder.


Here is how you can perform the same optimizations in FlashDevelop:

Number 1 is fairly easy: Just find the only drop-down menu in the main interface, and change it from “Debug” to “Release”.

tip1

With number 2 you follow the same instructions, but you can get to the menu to add an item by right-clicking on your project in the “Project” pane of the right column, or by going to “File”->”New”.

tip2

Number 3 is slightly more complicated. First you need to get to your project’s properties menu, which you can do one of several ways. Here is a screenshot of going through the “Project” menu:

tip3-1

Then, click on the “Compiler Options” tab, and select the “Advanced Compiler Options” by clicking on it and clicking the “…” button. Then add the line “-static-rsls=false” to it as shown(or append it on a new line if you have other options set already).

tip3-3

Now, you have to copy the “framework_3.2.*.swf” and “framework_3.2.*.swz” files to the “bin” directory in your project, and upload them to your site when you upload your app. These contain the Flex framework that will be cached by the Flash Player when you run your app. They are located in “flex_sdk_3\frameworks\rsls” in the Flex 3 SDK folder. Note that whatever version of the SDK you compiled your app with is the version you have to use the RSLs from. If you compile your app on on build, and then try to use the RSLs from another one(ie. you switched machines/reinstalled the sdk/use another ide that uses a different sdk version, etc.) you will get a message when your app loads about RSL 1 loading(but it never will). So, if you reinstall the SDK, or any of the things I mentioned recompile your app with the new version. *phew*

I hope these tips are helpful to you!

2 Comments


  1. Thanks for the contribution Alex! That is a good supplemental article to the information Serge discussed.

Leave a Reply

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