Hi, You can use the Selection Object for the same. Tracy already posted the link of docs.
Just wrote a quick and dirty example, look at it and read the comments in the code to know what is happening. ##SelectionObjectExample.mxml## <?xml version="1.0" encoding="iso-8859-1"?> <mx:Application width="800" height="600" xmlns:mx="http://www.macromedia.com/2003/mxml" > <mx:Script> <![CDATA[ var lastFocussedObject:Object = null; var beginIndex:Number; var endIndex:Number; function getSelectedText():String { //get the reference of currently focussed object. var obj:Object = ta.getFocus(); //store the reference of currently focussed object lastFocussedObject = obj; //check if it is a selectable textfield if(obj instanceof TextField && obj.selectable == true) { //get the selection based on beginIndex and endIndex beginIndex = Selection.getBeginIndex(); endIndex = Selection.getEndIndex(); var selectedText:String = obj.text.substring(beginIndex,endIndex); alert("Selected Text: " + selectedText); return selectedText } else { //return null when selected object is not a TextField return null; } } //this function restores the focus to the last selected object. function restoreFocus() { //set the focus back to the last focussed object Selection.setFocus(lastFocussedObject); //if it was TextField if(lastFocussedObject instanceof TextField) { //set the selection also Selection.setSelection(beginIndex, endIndex) beginIndex = endIndex = 0; } } ]]> </mx:Script> <mx:TextArea id="ta" width="300" height="200"/> <mx:TextArea id="ta2" width="300" height="200"/> <!-- We are using mouseDown & mouseUp instead of click, because that's how you can get the details of last focussed object before focus is shifted to button. --> <mx:Button id="btn" label="Get Selection" mouseDown="getSelectedText()" mouseUp="restoreFocus();" /> </mx:Application> Hope that helps -abdul -----Original Message----- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Reto M. Kiefer Sent: Thursday, May 26, 2005 10:31 PM To: Flexcoders Subject: [flexcoders] Access mouse selection Hello list, I searched for a reasonable time but got no working result. I'd like to know how do I access with ActionScript the selected text, the user can select with the mouse in a editable textarea. Just the selection, before copied or cut... Background I want to modify the selection and return the modifications just in time. I'm playing with an online thesaurus based on a webservice and I want to pass the selected text in a webservice call. Thanks in advance Reto Yahoo! Groups Links Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/