Apr 25

在前面的Flex的TextArea控件中如何利用htmlText属性以及condenseWhite属性紧缩HTML空格的例子中,我们了解了如何通过设置htmlText和condenseWhite属性,在TextArea中将HTML的空格进行紧缩。接下来的例子则演示了在RichTextEditor中,如何利用htmlText和condenseWhite属性,紧缩HTML标签的空格。

让我们先来看一下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.             private function checkBox_change(evt:Event):void {
  10.                 richTextEditor.textArea.condenseWhite = checkBox.selected;
  11.             }
  12.         ]]>
  13.     </mx:Script>
  14.  
  15.     <mx:String id="str" source="lorem.html" />
  16.  
  17.     <mx:ApplicationControlBar dock="true">
  18.         <mx:Form styleName="plain">
  19.             <mx:FormItem label="condenseWhite:">
  20.                 <mx:CheckBox id="checkBox"
  21.                         change="checkBox_change(event);" />
  22.             </mx:FormItem>
  23.         </mx:Form>
  24.     </mx:ApplicationControlBar>
  25.  
  26.     <mx:RichTextEditor id="richTextEditor"
  27.             htmlText="{str}"
  28.             width="100%"
  29.             height="100%" />
  30.  
  31. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:minidxer

written by Minidxer  |  tags: , , , , ,

Related Post

Leave a Reply