Pay for Hesitation: RichTextEditor 格式化文章

Pages

2008年3月18日 星期二

RichTextEditor 格式化文章

很常見的Rich Text Editor, 在flex裡面早就幫我們內建好了, 用來輔助user寫文章~

順便加了統計字數的DEMO: http://140.112.31.185/flextest/richtext.swf

ActionScript---------------------------------------
import mx.events.FlexEvent;
import mx.controls.TextArea;
import mx.controls.RichTextEditor;

private const MAX_CHARS:uint = 100;

private function richTextEditor_creationComplete(evt:FlexEvent):void {
RichTextEditor(evt.currentTarget).textArea.maxChars = MAX_CHARS;
}

private function richTextEditor_change(evt:Event):void {
var rte:RichTextEditor = evt.currentTarget as RichTextEditor;
var rteTA:TextArea = rte.textArea as TextArea;
rte.status = rteTA.length + "/" + rteTA.maxChars;
}
MXML-----------------------------------------------
<mx:RichTextEditor id="richTextEditor"
title="Rich Text Editor"
height="100%"
width="100%"
showToolTips="true"
change="richTextEditor_change(event);"
creationComplete="richTextEditor_creationComplete(event);" />

沒有留言: