Chase Brammer Thinking in Code

8Dec/080

Caching the Flex Framework – using a RSL

In a project recently, I was having a bug where fonts would load into the Flex Framework, but would never be rendered in the text field. The strange thing about this though is that it was only happening on select computers. This is a strange thing for Flex/Flash developers to run into because we pride ourselves in developing a ubiquitous platform that doesn’t change from OS to OS, and from browser to browser (I am looking at you CSS).

Tracking down why the fonts weren’t loading was a pain, because every computer I would get my hands on (thanks to VMware) would show the problem, and then it would magically disappear. The problem wasn’t in the code, however hard I looked and wanted to find it there. The problem was in the Flex framework.

The flex framework is usually compiled into the .SWF that a Flex project outputs, which adds about 500k to a project depending on what parts of the framework you use. But when you compile the framework into a project, you may not be getting the most recent or best framework for your application. But 99% of the time this doesn’t matter because you are getting what you need out of the framework. But getting the wrong framework, like what happened to me, causes some very frustrating problems.

Even though I was using the wrong framework, this didn’t affect most users, because Flex was defaulting to a cached Flex framework that the user had picked up somewhere else on the web. So, to force users to use the right framework, all that was needed was to use a RSL (runtime-shared-library).

What is an RSL? It is basically a package of code that has been put into a file by adobe.  This file can then be loaded in and cached IF the user doesn't already have it, but the great this is is that if the User does have it your download to the user is significanlty less..  These files however need to be placed on the local server and consist of the same file twice.  The default is an Adobe signed secure version called a .swz (pronounced swiz) and the second is swf that is a failsafe backup that contains the same code, but is not signed.

A nice side note on using and RSL is that file size will decrease by about 500k!

There are lots of ways to enable and choose an RSL. The easiest though is to just go to the project properties in flex, and choose your RSL. Then when you compile your project you will notice some extra files like framework_3.0.0.477.swf and framework_3.0.0.477.swz. These are adobe signed frameworks that are used in case the framework isn’t cached and needs to be downloaded.

One thing to note is that the flash player 9 framework that was used in the original shipment of Flex Builder 3 is the 3.0.0.477 framework.  But if you have updated your Flex SDK or download the latest version of flex you will notice that your framework files will be the updated to 3.2.0.3958

On one last note, the thing that helped to find this bug the most was the Flash Settings manager. Most people don’t realize that the Flex framework is not cached in the browser cache, it is cached in the Flash Player cache. To every computer to show the problem, I just had to disable the flash cache.





   

Pages

Categories

Blogroll

Archive

Meta