1
votes

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

1

1 Answers

3
votes

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.