[ Team LiB ] |
Recipe 8.24 Selecting Text with ActionScript8.24.1 ProblemYou want to highlight a portion of the text within a text field. 8.24.2 SolutionUse the Selection.setSelection( ) method. 8.24.3 DiscussionThe Selection class has a static method, setSelection( ), which highlights a portion of the text in the text field. The selection is applied to the text field that has focus (see Recipe 8.23). The setSelection( ) method takes two parameters:
For example: myTextField.text = "this is some text"; // Set the text value. Selection.setFocus("myTextField"); // Bring focus to the text field. Selection.setSelection(0, 4); // Highlight the word "this". 8.24.4 See Also |
[ Team LiB ] |