Selecting text in textbox via ActionScript in Flash

How do you select a portion of text in a textbox via actionscript?  Is this a property that can be set and/or read form actionscript?

Visual example of what I mean by selecting text in textbox:
http://www.databasedev.co.uk/image/cursor_default_selection.gif

Thanks in advance!
mediapandererAsked:
Who is Participating?
 
ArulPrasad1Connect With a Mentor Commented:
You can use the Selection object to achieve this:

Selection.setFocus(txtFieldInstanceName);
Selection.setSelection ( beingIndex, endIndex);

The first line sets Focus on the appropriate textfield. As you see in my code snippet, you'll have to pass the instance name of your textfield.

The second line, sets selection. the first parameter is the starting point, and the second is the end point.

You can have only one object in focus, in Flash. So if you click on another object, the selection you set as above will be lost.
0
 
mediapandererAuthor Commented:
Perfect, thanks!

Do you happen to know another way to highlight text in a textbox, not using the selection (to allow for clicking on other objects)?
0
 
ArulPrasad1Connect With a Mentor Commented:
If you are using AS3 and flash player 9, you can do this using the

alwaysShowSelection

property of textfields. Flash player 8 and below don't have this ability.
0
 
mediapandererAuthor Commented:
Perfect, thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.