User Guide

TextFormat 701
font (TextFormat.font property)
public font : String
A string that specifies the name of the font for text. The default value is null, which indicates
that the property is undefined.
Note: For Flash Lite, this property works for embedded fonts only. This property is not
supported for Arabic, Hebrew, and Thai.
Availability: ActionScript 1.0; Flash Lite 2.0
Example
The following example creates a text field and sets the font to Courier.
this.createTextField("mytext",1,100,100,100,100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = true;
var myformat:TextFormat = new TextFormat();
myformat.font = "Courier";
mytext.text = "this is my first text field object text";
mytext.setTextFormat(myformat);
getTextExtent (TextFormat.getTextExtent method)
public getTextExtent(text:String, [width:Number]) : Object
Returns text measurement information for the text string text in the format specified by
my_fmt. The text string is treated as plain text (not HTML).
The method returns an object with six properties:
ascent, descent, width, height,
textFieldHeight, and textFieldWidth. All measurements are in pixels.
If a
width parameter is specified, word wrapping is applied to the specified text. This lets you
determine the height at which a text box shows all of the specified text.
The
ascent and descent measurements provide, respectively, the distance above and below
the baseline for a line of text. The baseline for the first line of text is positioned at the text
field's origin plus its
ascent measurement.
The
width and height measurements provide the width and height of the text string. The
textFieldHeight and textFieldWidth measurements provide the height and width
required for a text field object to display the entire text string. Text fields have a 2-pixel-wide
gutter around them, so the value of
textFieldHeight is equal the value of height + 4;
likewise, the value of
textFieldWidth is always equal to the value of width + 4.