Mega Code Archive

 
Categories / Flex / Components
 

Get color for selected text in RichTextEditor

<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="600"     height="500">     <mx:Script>         import mx.controls.textClasses.TextRange;         [Bindable]                  public var htmlData:String="<textformat leading='2'><p align='center'><b><font size='20'>HTML Formatted Text</font></b></p></textformat>";         public function changeSelectionText():void {             var sel:TextRange = rte1.selection;             var selLength:int = sel.endIndex - sel.beginIndex;             if (selLength) {                                  t1.text+="\nOriginal Font Color: " + sel.color;             }         }       </mx:Script>     <mx:RichTextEditor id="rte1" htmlText="{htmlData}" width="100%"         height="100%" mouseUp="changeSelectionText()" />     <mx:TextArea editable="false" id="t1" fontSize="12"         fontWeight="bold" width="300" height="180" /> </mx:Application>