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.

myformat.font = "Courier";<br />

mytext.text = "this is my first test field object text";<br />

mytext.setTextFormat(myformat);<br />

getTextExtent (TextFormat.getTextExtent method)<br />

public getTextExtent(text:String, [width:Number]) : Object<br />

Returns text measurement information for the text string text in the format specified by<br />

my_fmt. The text string is treated as plain text (not HTML).<br />

The method returns an object with six properties: ascent, descent, width, height,<br />

textFieldHeight, <strong>and</strong> textFieldWidth. All measurements are in pixels.<br />

If a width parameter is specified, word wrapping is applied to the specified text. This lets you<br />

determine the height at which a text box shows all of the specified text.<br />

The ascent <strong>and</strong> descent measurements provide, respectively, the distance above <strong>and</strong> below<br />

the baseline for a line of text. The baseline for the first line of text is positioned at the text<br />

field's origin plus its ascent measurement.<br />

The width <strong>and</strong> height measurements provide the width <strong>and</strong> height of the text string. The<br />

textFieldHeight <strong>and</strong> textFieldWidth measurements provide the height <strong>and</strong> width<br />

required for a text field object to display the entire text string. Text fields have a 2-pixel-wide<br />

gutter around them, so the value of textFieldHeight is equal the value of height + 4;<br />

likewise, the value of textFieldWidth is always equal to the value of width + 4.<br />

If you are creating a text field based on the text metrics, use textFieldHeight rather than<br />

height <strong>and</strong> textFieldWidth rather than width.<br />

TextFormat 1255

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

Saved successfully!

Ooh no, something went wrong!