• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. Controlling Text > Controlling the Selection Within Text Fields

Controlling the Selection Within Text Fields

When you have a focused text field, either by using ActionScript or by a viewer’s clicking it with the pointer, you can control the selection or insertion-point position inside it. This technique lets you direct your viewers’ attention to particular characters or words they’ve entered, perhaps to point out errors or misspellings. It also lets you keep track of the insertion-point position, much the way that the _xmouse and _ymouse properties let you keep track of the location of the viewer’s mouse pointer. You can also select certain parts of the text field and replace just those portions with different text.

The position of each character in a string is numbered and used as the index for the methods of the Selection class, just as the index for the setTextFormat() method is used. The first character is assigned the index of 0, the second character is 1, and so on. If an insertion point isn’t positioned within a text field when Flash retrieves the selection index, it returns a value of –1.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint