For certain kinds of text-heavy work, especially word games, educational exercises, and similar activities, ActionScript has been lacking in the ability to quickly access partial content from text fields. It has always been possible to accomplish some text parsing tasks by working with the text data within the field, using string manipulation. However, it was not previously possible, or in some cases not very easy, to get information about a specific line or paragraph or, in particular, mouse-text interaction.
ActionScript 3.0 comes closer to what some of us are looking for with the addition of a handful of methods for looking directly into fields. To demonstrate these features, we've divided them up into two groups of methods. The first focuses on characters and fields, the second on lines. In both cases, data originates from mouse interaction. In each of the two source files we'll discuss, the user drags a virtual loupe, or magnifying glass, around the screen that reveals information from a text field below the mouse.
These examples are presented in a diagnostic fashion, but the methods they demonstrate have many practical uses. Being able to pull text from a single line of a text field, and knowing where the lines break in a field, are two good examples. This information can be great for truncating lines that may be too long for an interface, or for determining when to insert a page break.
The first exercise we'll discuss is in the text_line_data.fla ...