Sep 26, 2008

Implementing the Flash Player Cache feature

In this article I will be telling you how to creating a dynamically linked application i.e how to implement Flash Player cache feature by using RSLs with Flex Builder

But let us first know what is a statically linked application and a dynamically linked application

Statically linked application - Flex framework code and the application code will make the SWF file increasing the size of the SWF file

Dynamically linked application - Flex framework code will be added dynamically to the SWF code thus reducing its size
If you want to check the result of the above mentioned feature live the follow the steps

1. Create any flex application with some code

2. Get the true size of the application - Follow the steps
1. By default, Flex Builder adds debugging information to SWF files, so in order to see the true size of the application,
turn off the debugging information
2. To do this, add -debug=false to the Additional Compiler Arguments section of the Flex Compiler Properties dialog box

3. Check the size of the application by viewing the properties of the application’s SWF file created in the bin directory
Note down the size

4. Now go to Project Properties (right click on Flex project and select properties), then choose the Flex Build Path properties
and click the Library Path tab

5. In the Framework Linkage pop-up menu, change the link type from “Merged into code” to “Runtime shared library (RSL).”
Click OK to save the changes.

6. Build the project

7. Now check the file size of the SWF file. You will definitely be surprised!!!!

266268 bytes - BEFORE
- 125020 bytes - AFTER
——
141248 bytes - DIFFERENCE IN SIZE

Important things

When you choose the option to use RSLs, all of the debug information is removed.
So you can easily switch between a statically linked application and a dynamically linked application just by toggling the option in the Framework Linkage pop-up menu from “Merged into code” to “Runtime shared library (RSL).”

The framework RSL is the only RSL that is configured by default in the flex-config.xml file because every Flex application uses over 100K of framework classes. If you do add RSLs, the compiler will always load any RSLs you specify whether or not they are used by your application.

For more information on this check the following link
http://www.adobe.com/devnet/flex/articles/flash_player_cache_print.html

1 comment: