jchittoda1
asked on
runtime CSS change in flex
Hi All,
I am working in Flex. I want to set style bold / italic / underline depending upon the selection of a buttons.
I am using the following to set the font style/weight but it is not working.
I want to set the bold and italic formatting dynamically upon clicking BOLD or ITALIC button given in the application.
Please help me with this.
Thanks
I am working in Flex. I want to set style bold / italic / underline depending upon the selection of a buttons.
I am using the following to set the font style/weight but it is not working.
I want to set the bold and italic formatting dynamically upon clicking BOLD or ITALIC button given in the application.
Please help me with this.
Thanks
var txt:TextInput = new TextInput();
txt.setStyle("font-weight", "bold");
txt.setStyle("font-style", "italic");
what version of flex are you on ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Surprisingly (and annoyingly) CSS in Flex uses different style property names than are used in Flex. So, as Fuzzy Logic pointed out, while inside a <Style> tag you need to say "font-weight," when you're setting the style dynamically in Actionscript, you need to use the Flex-standard names for the properties: "fontWeight."
Another example:
background-color = backgroundColor
The full list of component properties can be found in the Flex docs from Adobe. In particular, here it is for the TextInput component:
http://livedocs.adobe.com/flex/3/langref/mx/controls/TextInput.html#styleSummary
As you already know, you say txt.setStyle("nameOfStyle" , "propertyValue"); or you can get the style like this:
txt.getStyle("nameOfStyle" );
Or you can get more complex:
txt1.setStyle("nameOfStyle ", txt2.getStyle("nameOfStyle "));
Another example:
background-color = backgroundColor
The full list of component properties can be found in the Flex docs from Adobe. In particular, here it is for the TextInput component:
http://livedocs.adobe.com/flex/3/langref/mx/controls/TextInput.html#styleSummary
As you already know, you say txt.setStyle("nameOfStyle"
txt.getStyle("nameOfStyle"
Or you can get more complex:
txt1.setStyle("nameOfStyle