Flex中如何通过backgroundColor样式设置RichTextEditor控件内TextArea的背景颜色的例子

By Minidxer | August 27, 2008

接下来的例子演示了Flex中如何通过backgroundColor样式,设置RichTextEditor控件内TextArea的背景颜色。

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


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

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application name="RichTextEditor_backgroundColor_test"
  3.         xmlns:mx="http://www.adobe.com/2006/mxml"
  4.         layout="vertical"
  5.         verticalAlign="middle"
  6.         backgroundColor="white">
  7.  
  8.     <mx:Script>
  9.         <![CDATA[
  10.             import mx.events.ColorPickerEvent;
  11.  
  12.             private function colorPicker_change(evt:ColorPickerEvent):void {
  13.                 richTextEditor.textArea.setStyle("backgroundColor", evt.color);
  14.             }
  15.         ]]>
  16.     </mx:Script>
  17.  
  18.     <mx:ApplicationControlBar dock="true">
  19.         <mx:Form styleName="plain">
  20.             <mx:FormItem label="backgroundColor:">
  21.                 <mx:ColorPicker id="colorPicker"
  22.                         selectedColor="0xFFFFFF"
  23.                         change="colorPicker_change(event);" />
  24.             </mx:FormItem>
  25.         </mx:Form>
  26.     </mx:ApplicationControlBar>
  27.  
  28.     <mx:RichTextEditor id="richTextEditor" />           
  29.  
  30. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Flex | 1 Comment » | 150 views Tags: , , , ,

Search Posts