Flex Runtime CSS

I got a couple of questions about this at Flex Camp so I thought I'd put together a quick example of using runtime CSS. The code is pretty simple. The key is to remember that the CSS you load at runtime must be compiled into a separate SWF file; one for each style sheet.

In Flex Builder, simply right-click on your CSS file and select Compile CSS to SWF.

Also remember that when specifying the style sheet in your StyleManager.loadStyleDeclarations() call, refer to the SWF, not the CSS file.

Check out this sample. View Source is enabled. NOTE: Ignore the error and select RuntimeCSS_mxml.html to see the main source code. Source code is downloadable from the bottom-left corner of the Vew Source screen.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Ed's Gravatar There is a way to do that without to compile the CSS to SWF using the CSSLoader. But there are a couple of things that still will not work well and i believe that reffer to the compiled CSS's as well. You can see more details about it here: http://www.1smartsolution.com/blog/index.cfm/2007/...
# Posted By Ed | 11/18/07 11:49 AM
Muhammad saqib's Gravatar Today i'm sooo much excited, i'm new to flex and i had to complete my task for my company, this blog helped me sooo much that i got success in changing colors and themes of my application using external css on run time.. You are greatttt...
Thanks
# Posted By Muhammad saqib | 1/29/08 7:41 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.