RichTextEditor 提示您还可以输入多少字符

姜俊友
2023-12-01

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
 <mx:RichTextEditor id="rich" x="387" y="19" title="Title" width="362" height="187" creationComplete="setChars()" change="showText()">
 </mx:RichTextEditor>


 <mx:Script>
 <![CDATA[
  //初始化时限制输入最大字符
  private function setChars():void{
   this.rich.textArea.maxChars=20;
  }
  //richTextEdit
  function showText():void{
   var charLength:Number=rich.textArea.maxChars;
   var textLength:Number=rich.text.length;
   rich.title="你还可以输入:"+(charLength-textLength);
  }
 ]]>
 </mx:Script>
</mx:Application>

 类似资料: