03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

This method works correctly only with fonts that include character metric information; by<br />

default, Flash does not include this information for static text fields. Therefore, text that is<br />

selected might not appear to be selected onscreen. To ensure that all selected text appears to be<br />

selected, you can force the Flash authoring tool to include the character metric information<br />

for a font. To do this, in the library, include the font used by the static text field, <strong>and</strong> in<br />

Linkage options for the font, select Export for <strong>ActionScript</strong>.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 7 - The SWF file must be published for Flash<br />

Player 6 or later, <strong>and</strong> must be played in Flash Player 7 or later.<br />

Parameters<br />

start:Number - The position of the first character to select. Valid values for start are 0<br />

through TextSnapshot.getCount() - 1. If start is a negative value, 0 is used.<br />

end:Number - An integer that is 1+ the index of the last character to be examined. Valid values<br />

for end are 0 through TextSnapshot.getCount(). The character indexed by the end<br />

parameter is not included in the extracted string. If you omit this parameter,<br />

TextSnapshot.getCount() is used. If the value of end is less than or equal to the value of<br />

start, start + 1 is used.<br />

select:Boolean - A Boolean value that specifies whether the text should be selected (true)<br />

or not (false).<br />

Example<br />

The following example illustrates how to use this method. To use this code, place a static text<br />

field that contains the text "TextSnapshot Example" on the Stage. In the library, include the<br />

font used by the static text field, <strong>and</strong> in Linkage options for the font, select Export for<br />

<strong>ActionScript</strong>. Add the following <strong>ActionScript</strong> to Frame 1 of the Timeline:<br />

var my_snap:TextSnapshot = this.getTextSnapshot();<br />

var count:Number = my_snap.getCount();<br />

my_snap.setSelected(0, 4, true);<br />

my_snap.setSelected(1, 2, false);<br />

var theText:String = my_snap.getSelectedText(false);<br />

trace(theText); // Text<br />

See also<br />

getCount (TextSnapshot.getCount method)<br />

TextSnapshot 1285

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!