getSelected (TextSnapshot.getSelected method)
public getSelected(start:Number, [end:Number]) : Boolean
Returns a Boolean value that specifies whether a TextSnapshot object contains selected text in
the specified range.
To search all characters, pass a value of
for
, and
(or any
0
start
TextSnapshot.getCount()
very large number) for
. To search a single character, pass the
parameter a value that is
end
end
one greater than the
parameter.
start
Availability: ActionScript 1.0; Flash Player 7 - The SWF file must be published for Flash
Player 6 or later, and must be played in Flash Player 7 or later.
Parameters
- The index position of the first character to be examined. Valid values for
start:Number
are
through
. If
is a negative value,
is used.
start
0
TextSnapshot.getCount() - 1
start
0
[optional] - The index position that is one greater than the last character to be
end:Number
examined. Valid values for
are
through
. The character
end
0
TextSnapshot.getCount()
indexed by the
parameter is not included in the extracted string. If you omit this
end
parameter,
is used. If the value of
is less than or equal to the
TextSnapshot.getCount()
end
value of
,
is used.
start
start + 1
Returns
- A Boolean value that indicates whether at least one character in the given range has
Boolean
been selected by the corresponding
method (
);
TextSnapshot.setSelected()
true
otherwise,
.
false
Example
The following example illustrates how to use this method. To use this code, place a static text
field that contains the text "TextSnapshot Example" on the Stage. In the library, include the
font used by the static text field, and in Linkage options for the font, select Export for
ActionScript. Add the following ActionScript to Frame 1 of the Timeline:
var my_snap:TextSnapshot = this.getTextSnapshot();
var count:Number = my_snap.getCount();
my_snap.setSelected(0, 4, true);
my_snap.setSelected(1, 2, false);
var firstCharIsSelected:Boolean = my_snap.getSelected(0, 1);
var secondCharIsSelected:Boolean = my_snap.getSelected(1, 2);
trace(firstCharIsSelected); // true
trace(secondCharIsSelected); // false
TextSnapshot
1255
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?