views:

1045

answers:

1

Is there a way to restrict the number of characters in the Flex Rich Text Editor? I guess there should be, since it's possible in a textarea. So, if I could get hold of the textarea contained in the rich text editor, I would be able to do it

+1  A: 

I think this would be fairly easy in actionscript, although I'm not exactly sure how one would do it in mxml. It appears that there are two children that are contained in the RichTextEditor, one of them being TextArea. According to the documentation (http://livedocs.adobe.com/flex/3/langref/mx/controls/RichTextEditor.html#propertySummary), you can access the subcontrols like so:

myRTE.toolBar2.setStyle("backgroundColor", 0xCC6633);

With myRTE being the instance of your text editor. So my guess would be something like this would work:

myRTE.textArea.maxChars = 125;

With 125 being the number a characters you would want restricted to.

bkildow
In mxml it would just be<mx:RichTextEditor id="rte1"><mx:TextArea maxChars="125" /></mx:RichTextEditor>
adamcodes