Set selection range for TextRange : TextRange « Components « Flex






Set selection range for TextRange

Set selection range for TextRange
      

<?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
        public function alterText():void {
            var tr1:TextRange = new TextRange(ta1, false,ta1.text.indexOf("is", 0), ta1.text.indexOf(".", 0));
            tr1.htmlText="<i>italic HTML text</i>"
            var tr2:TextRange = new TextRange(ta1, true, ta1.text.indexOf("t",0), ta1.text.length-1);
            ta1.setSelection(0, 3);
        }
      </mx:Script>
    <mx:TextArea id="ta1" fontSize="12" fontWeight="bold" width="100%"
        height="100">
        <mx:text>
            this is a test.
        </mx:text>
    </mx:TextArea>
    <mx:Button label="Alter Text" click="alterText();" />
</mx:Application>

   
    
    
    
    
    
  








Related examples in the same category

1.Set html text to TextRangeSet html text to TextRange
2.Set color for TextRangeSet color for TextRange
3.Set font size for TextRangeSet font size for TextRange
4.Set font style for TextRangeSet font style for TextRange
5.Set font weight for TextRangeSet font weight for TextRange
6.TextRange Selected TextTextRange Selected Text
7.Set the Style Properties for Text RangesSet the Style Properties for Text Ranges