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.
- 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.
- Move your panels into modules(see movie)
- 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”.
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”.
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:
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).
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!