Flex中如何设置TextArea控件中的无效(disabled)文本颜色的例子

By Minidxer | April 27, 2008

接下来的例子演示了Flex中如何通过设定TextArea控件的color和disabledColor样式,设定文本在有效,无效状态下的颜色。

让我们先来看一下Demo(可以右键View Source或点击这里察看源代码


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="vertical"
  4.         verticalAlign="middle"
  5.         backgroundColor="white">
  6.  
  7.     <mx:Script>
  8.         <![CDATA[
  9.             import mx.utils.StringUtil;
  10.         ]]>
  11.     </mx:Script>
  12.  
  13.     <mx:String id="lorem" source="lorem.html" />
  14.  
  15.     <mx:ApplicationControlBar dock="true">
  16.         <mx:Form styleName="plain">
  17.             <mx:FormItem label="color:">
  18.                 <mx:ColorPicker id="colorPicker1"
  19.                         selectedColor="black" />
  20.             </mx:FormItem>
  21.             <mx:FormItem label="disabledColor:">
  22.                 <mx:ColorPicker id="colorPicker2"
  23.                         selectedColor="red" />
  24.             </mx:FormItem>
  25.             <mx:FormItem label="enabled:">
  26.                 <mx:CheckBox id="checkBox"
  27.                         selected="true" />
  28.             </mx:FormItem>
  29.         </mx:Form>
  30.     </mx:ApplicationControlBar>
  31.  
  32.     <mx:TextArea id="textArea"
  33.             condenseWhite="true"
  34.             color="{colorPicker1.selectedColor}"
  35.             disabledColor="{colorPicker2.selectedColor}"
  36.             enabled="{checkBox.selected}"
  37.             width="100%"
  38.             height="100%"
  39.             initialize="textArea.htmlText = StringUtil.trim(lorem);" />
  40.  
  41. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:minidxer

Topics: Flex | 2 Comments » | 144 views Tags: , , , , , ,

Related Post

2 comments | Add One

Leave a Comment

Name(*):

E-Mail(*) :

Website :

Comments :

Search Posts

赞助商链接

Archives