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.

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>. To test the code, run the SWF file <strong>and</strong> point the mouse pointer to the onscreen<br />

text.<br />

var my_ts:TextSnapshot = getTextSnapshot();<br />

this.onMouseMove = function() {<br />

var hitIndex:Number = my_ts.hitTestTextNearPos(_xmouse, _ymouse, 0);<br />

my_ts.setSelected(0, my_ts.getCount(), false);<br />

if (hitIndex >= 0) {<br />

my_ts.setSelected(hitIndex, hitIndex + 1, true);<br />

}<br />

};<br />

See also<br />

getTextSnapshot (MovieClip.getTextSnapshot method), _x (MovieClip._x<br />

property), _y (MovieClip._y property)<br />

setSelectColor (TextSnapshot.setSelectColor<br />

method)<br />

public setSelectColor(color:Number) : Void<br />

Specifies the color to use when highlighting characters that were selected with the<br />

TextSnapshot.setSelected() method. The color is always opaque; you can't specify a<br />

transparency value.<br />

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

however, by default, <strong>Adobe</strong> Flash does not include this information for static text fields.<br />

Therefore, the method might return -1 instead of an index value. To ensure that an index<br />

value is returned, you can force the Flash authoring tool to include the character metric<br />

information for a font. To do this, add a dynamic text field that uses that font, select<br />

Character Options for that dynamic text field, <strong>and</strong> then specify that font outlines should be<br />

embedded for at least one character. (It doesn't matter which characters you specify, nor if<br />

they are the characters used in the static text fields.)<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 />

TextSnapshot 1283

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

Saved successfully!

Ooh no, something went wrong!