分享按钮

Flex中如何设置CheckBox标签(Label)与主题(theme )颜色的例子

 Flex中如何设置CheckBox标签(Label)与主题(theme )颜色的例子

By Minidxer | June 28, 2009

接下来的例子演示了Flex中如何设置CheckBox标签(Label)与主题(theme )颜色。

让我们先来看一下Demo可以点击这里察看源代码):

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application name="CheckBox_color_test"
  3.         xmlns:mx="http://www.adobe.com/2006/mxml"
  4.         layout="vertical"
  5.         verticalAlign="middle"
  6.         backgroundColor="white">
  7.  
  8.     <mx:Style>
  9.         CheckBox {
  10.             fontWeight: bold;
  11.             iconColor: green;
  12.         }
  13.  
  14.         .selectedStyle {
  15.             color: green;
  16.             textRollOverColor: green;
  17.             textSelectedColor: green;
  18.             themeColor: green;
  19.         }
  20.  
  21.         .unselectedStyle {
  22.             color: red;
  23.             textRollOverColor: red;
  24.             textSelectedColor: red;
  25.             themeColor: red;
  26.         }
  27.     </mx:Style>
  28.  
  29.     <mx:Script>
  30.         <![CDATA[
  31.             private function checkBox_change(evt:Event):void {
  32.                 var tgt:CheckBox = evt.currentTarget as CheckBox;
  33.                 if (tgt.selected) {
  34.                     tgt.styleName = "selectedStyle";
  35.                 } else {
  36.                     tgt.styleName = "unselectedStyle";
  37.                 }
  38.             }
  39.         ]]>
  40.     </mx:Script>
  41.  
  42.     <mx:CheckBox id="checkBox"
  43.             label="CheckBox"
  44.             selected="false"
  45.             styleName="unselectedStyle"
  46.             change="checkBox_change(event);" />
  47.  
  48. </mx:Application>
posted @ 2011-08-14 14:36  草莓在努力  阅读(219)  评论(0编辑  收藏  举报