Flex中如何设置CheckBox标签(Label)与主题(theme )颜色的例子
By Minidxer | June 28, 2009
接下来的例子演示了Flex中如何设置CheckBox标签(Label)与主题(theme )颜色。
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application name="CheckBox_color_test"
- xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Style>
- CheckBox {
- fontWeight: bold;
- iconColor: green;
- }
- .selectedStyle {
- color: green;
- textRollOverColor: green;
- textSelectedColor: green;
- themeColor: green;
- }
- .unselectedStyle {
- color: red;
- textRollOverColor: red;
- textSelectedColor: red;
- themeColor: red;
- }
- </mx:Style>
- <mx:Script>
- <![CDATA[
- private function checkBox_change(evt:Event):void {
- var tgt:CheckBox = evt.currentTarget as CheckBox;
- if (tgt.selected) {
- tgt.styleName = "selectedStyle";
- } else {
- tgt.styleName = "unselectedStyle";
- }
- }
- ]]>
- </mx:Script>
- <mx:CheckBox id="checkBox"
- label="CheckBox"
- selected="false"
- styleName="unselectedStyle"
- change="checkBox_change(event);" />
- </mx:Application>