Applying styles at run time to your flex application.here there are two things to consider
1.defining ur styles in a .css file.
Here u have to define ur styles in a .css file for various controls or anything according to ur need. include them in the same folder.
example: style1.css
Application{
backgroundcolor=#ff00ff;
———–
———} any style definition
2.compile them to generate .swf files.
using adobe flex builder commond prompt compile ur .css file.i.e first copy the .css files to flex builder folder and then at cmd prompt use the command
>mxmlc style1.css
it generates ur .swf file at the flex builder folder (c:prog file/flex –/style1.swf) now take the generated .swf file to ur flex project folder/bin/ paste it.
now the required .swf files are ready.
3.invoke them at run time using some code.
var currentTheme:String=style1;
private function loadStyle():void
{
var eventDispatcher:IEventDispatcher =
StyleManager.loadStyleDeclarations(currentTheme + “.swf”);
eventDispatcher.addEventListener(StyleEvent.COMPLETE, completeHandler);
}
u can include as many .css file and compile .swf files in to ur project and invoke them at runtime.
for any guidence leave a message

May 19, 2008 at 8:31 am |
excellent article and we r waiting for this type of articles
August 27, 2008 at 6:21 am |
how to store style information on server
August 28, 2008 at 2:04 pm |
you have to put the generated swf in the same folder of the Application, then that style is loaded.
April 8, 2009 at 7:10 am |
Hi
i have done custom css using mx.styles.StyleManager. Once i create the css run time using flex explorer.
im stuckup with generate css code/ saving and apply in run time.
do u have any idea.
regards
ganesh
April 9, 2009 at 7:37 am |
Hi,
You’s generating the CSS code at runtime and want to load that CSS to the APP., then for this too we can follow the same technique, we got to send the CSS code to the server and compile it there and generate the compiled file[.swf] and load that file.Or we got to load the CSS code using the StyleManager Class and its methods ,like using the getStyleDeclaration,setStyle …, write an Algorithm to parse the CSS generated code and read that parsed code in to the methods which generates the style at runtime.
Hope this helps.
regards,
kumar.