3/15/2010 3:31:30 AM
Title:
Flash Text Input
Hi all,
i want to highlight text in text input component on mouse click. is there any way?
3/15/2010 9:56:25 AM
Check the following code it selects the text specified by giving the starting index and ending index. Remember that first you need to set focus , otherwise the selection is not visible.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="1024" minHeight="768">
<mx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
//set the focus to text box
txtBox.setFocus()
//select the text starting from 8 to 15 index
txtBox.setSelection(8,15);
}
]]>
</mx:Script>
<mx:TextInput id="txtBox" text=" asad aadaa dadad ada das dadad asd a">
</mx:TextInput>
<mx:Button label=" Click to select Text" mouseUp="button1_clickHandler(event)" x="400">
</mx:Button>
</mx:Application>