This topic has been discussed quite a bit elsewhere so it is difficult to add much to the conversation, but I did experience a few issues that I haven’t seen described yet and some that bear repeating.
The basic idea here is that we want to compile a CSS file into a swf and load it at runtime. I used a configuration XML file to specify the actual style setting for my app rather than put an mx:Style node in my mxml anywhere, or hardcode the path to the style swf.
Both Flex Builder 2 and the Eclipse plug-in for FB2 have the ability to compile CSS files for you. I work in the Eclipse plug-in for FB2, so all of my experience is from that environment. Supposedly, all you have to do is right click on them in the Explorer/Navigator window of the IDE and select “Compile to SWF”. However I had multiple issues with this and found very few resources that describe the dependencies of the CSS compilation. Through trial and error, this is what I have discovered.
The CSS file must be at the root of the project. If it is not, compilation will fail with mxmlc telling you that the source file is not correctly packaged. If you try to package it in a similar fashion to an AS source file, you will receive a syntax violation.
Also, if your CSS file uses any skins that utilize the ClassReference facility those classes and their entire class hierarchy must exist solely within your project. If you utilize classes that exist in externally linked directories or classes that extend other classes in externally linked directories, compilation will fail with the type declarations of these externally linked classes being unrecognized. The only workaround I found for this was specifying the source-path and library-path command line parameters for mxmlc myself and compiling manually. Luckily I had access to an ANT script that was updated fairly easily to support this, but it is still annoying not to be able to compile certain skins directly within Flex Builder 2.
If anyone knows how to circumvent these issues I would be all ears. Otherwise, I hope this saves you some time from banging your head into your keyboard.
-Casey