Applying styles at run time to flex application

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.

[showmyads]
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

Advertisements

5 Responses to Applying styles at run time to flex application

  1. gyani says:

    excellent article and we r waiting for this type of articles

  2. monali says:

    how to store style information on server

  3. kumargandhi says:

    you have to put the generated swf in the same folder of the Application, then that style is loaded.

  4. Ganesh says:

    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

  5. kumargandhi says:

    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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: