MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 798

Actionscript language reference
Table of Contents

Advertisement

Description
Method; specifies a range of characters in a TextSnapshot object to be selected or deselected.
Characters that are selected are drawn with a colored rectangle behind them, matching the
bounding box of the character. The color of the bounding box is defined by
TextSnapshot.setSelectColor()
To select or deselect all characters, pass a value of 0 for
any very large number) for
Because characters are individually marked as selected, you can issue this command multiple
times to select multiple characters; that is, using this command does not deselect other characters
that have been set by this command.
The colored rectangle that indicates a selection is displayed only for fonts that include character
metric information; by default, Flash does not include this information for static text fields. In
some cases, this behavior means that text that is selected won't appear to be selected onscreen.
Example
The following example illustrates how to use this method. To use this code, place a static text field
containing the text "TextSnapshot Example" on the Stage.
Note: If characters don't appear to be selected when you run the code, you must also place a
dynamic text field on the Stage. See "Description" in this entry.
// This example assumes that the movie clip contains
// the static text "TextSnapshot Example"
var my_snap:TextSnapshot = this.getTextSnapshot();
var count:Number = my_snap.getCount();
my_snap.setSelectColor(0xFF0000); // Set the selection color to red.
my_snap.setSelected(0, 4, true); // Select the first four characters.
my_snap.setSelected(1, 2, false); // Deselect the second character (leaving
the rest selected).
var firstCharIsSelected:Boolean = my_snap.getSelected(0, 1);
var secondCharIsSelected:Boolean = my_snap.getSelected(1, 2);
var theText:String = my_snap.getSelectedText(false); // get the selected text
trace(theText); // output: Txt
trace(firstCharIsSelected); // output: true
trace(secondCharIsSelected); // output: false
798
Chapter 7: ActionScript for Flash
.
. To specify a single character, pass a value of
to
and
from
TextSnapshot.getCount()
from+1
(or
for
.
to

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents