Two RSL related gotcha's in Flex

Submitted by Falken on Thu, 05/28/2009 - 10:19

The other day I came across two little gotcha's when using [node:1498,title="Runtime Shared Libraries"] in Flex. The first is an issue when using RSL and 'monkey patched' SDK classes, and the other is problems Flex Builder introduces for you when using it to compile CSS files.

Like many people, we use the 'monkey patch' technique to apply important fixes without waiting for the main Flex SDK to be updated. However, if you use (and you really should be) RSL to reduce your applications file size, this will undo the monkey patch and you'll get the old behaviour back again.
In this case, we needed the fix to DateFormatter from #SDK-18000 so it was good to find a workaround.
As we already use a common custom preloader across all our projects for branding reasons, it was easy enough to incorporate a reference to DateFormatter in a project-specific sub-class.

However, I then noticed that something was wrong with the runtime skinning of our application. We use StyleManager to load compiled Flex CSS files to change colors and so on, and the error handler for loadStyleDeclarations was firing, saying "could not load RSL".
This is odd, as CSS files don't need any part of the framework, and in any case the RSL has already been loaded by the main application.
There is a note in the Adobe bug list (#
FB-15470) about a similar issue when loading modules but I also came across
It seems when you right click on a .css file in Flex Builder and choose 'compile CSS to SWF' Flex Builder incorrectly uses the same library settings as the main project, which causes the CSS to fail to be loaded.

This is apperently fixed in Flexash Builder 4 however, in the meantime there is a workaround (or two), but it's not as neat as the previous one.
You can either set up a seperate Builder project to use just to compile the .css files to .swf, and make sure the new project has the framework linkage set to 'external' in the project properties, or you can use the command line compiler to build the RSLs instead of Builder :

 -output card-server_1.2/src/bin/Foo.swf

I don't know if Adobe will make further updates for Builder 3 now version 4 is due out soonish, but we'll see as I've left a note on the issue, and opened #FB-20032 so vote for that if you'd like to see it fixed, as it's broken in Builder 4 too.