Get text indexes
<?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