tags:

views:

526

answers:

2

i used blue.css and also beige.css in flex .i have theme combobox for user changed theme dynamically so i stroed

[Bindable] private var pickcss:Array=["blue.css","beige.css"];

private function css_initializeHandler(event:Event):void

    {
        pickcssComboBox.selectedIndex = pickcss.indexOf(0);
     }

private function css_changeHandler(event:Event):void {

//here how will i apply
styleid= [ pickcssComboBox.selectedItem ]; }

" mx:Label text="Theme"/>

"mx:ComboBox id="pickcssComboBox" dataProvider="{pickcss}" initialize="css_initializeHandler(event)" change="css_changeHandler(event)" width="110"/>"

i used in style not have id so how can i do ? if u know plz explain

+3  A: 

First, to load style sheets dynamically you need to compile them into separate .swf files. This can be done with mxmlc (or in Flex Builder by right-clicking on the css file and choosing "Compile CSS to SWF"). Then, to load the style-swf, you use the StyleManager

StyleManager.loadStyleDeclarations("blue.swf");

When you want to switch between styles, you'll also want to unload the previous style. So, assuming you put the name of css file in your combobox, in your css_changeHandler you'll do something like this:

StyleManager.unloadStyleDeclarations(styleid)
styleid = pickcssComboBox.selectedItem;
StyleManager.loadStyleDeclarations(styleid);

See Loading style sheets at run time for more details.

Wouter Coekaerts
Very very useful to me . thanks Wouter Coekaerts .how do i set style id .i put name of css file in combobox like Blue theme and beige theme it showing properly . but how to switch
R.Vijayakumar