TextFormat.getTextExtent()
951
TextFormat.getTextExtent()
Availability
Flash Player 6. The optional
width
parameter is supported in Flash Player 7.
Usage
my_fmt
.getTextExtent(
text:String
, [
width:Number
])
: Object
Parameters
text
A string.
width
An optional number that represents the width, in pixels, at which the specified text
should wrap.
Returns
An object with the properties
width
,
height
,
ascent
,
descent
,
textFieldHeight
,
textFieldWidth
.
Description
Method; 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.
If you are creating a text field based on the text metrics, use
textFieldHeight
rather than
height
and
textFieldWidth
rather than
width
.
Summary of Contents for FLASH MX
Page 1: ...ActionScript Language Reference ...
Page 20: ...20 Contents ...
Page 24: ...24 Chapter 1 Introduction ...
Page 145: ...Button onKeyDown 145 See also Button onKeyUp ...
Page 202: ...202 Chapter 2 ActionScript Language Reference See also break default strict equality switch ...
Page 282: ...282 Chapter 2 ActionScript Language Reference See also break continue while ...
Page 383: ...LoadVars addRequestHeader 383 See also XML addRequestHeader ...
Page 388: ...388 Chapter 2 my_lv load place a valid URL pointing to a text file here ...
Page 463: ...Microphone setRate 463 See also Microphone rate ...
Page 469: ...Microphone silenceLevel 469 See also Microphone gain Microphone setSilenceLevel ...
Page 480: ...480 Chapter 2 ActionScript Language Reference See also Mouse addListener ...
Page 529: ...MovieClip globalToLocal 529 See also MovieClip getBounds MovieClip localToGlobal ...
Page 612: ...612 Chapter 2 ActionScript Language Reference See also MovieClipLoader onLoadStart ...
Page 623: ...NetConnection class 623 See also NetStream class Video attachVideo ...
Page 649: ...Number 649 See also NaN Number class ...
Page 679: ...on 679 on release trace X this _x trace Y this _y stopDrag See also onClipEvent ...
Page 683: ...onUpdate 683 buttonLabel textColor my_mc labelColor ...
Page 788: ...788 Chapter 2 ActionScript Language Reference See also private public ...
Page 1001: ...Video height 1001 my_mc _height my_mc my_video height See also MovieClip _height Video width ...
Page 1022: ...1022 Chapter 2 ActionScript Language Reference See also XML createElement ...
Page 1057: ...XML xmlDecl 1057 See also XML docTypeDecl XML toString ...
Page 1070: ...1070 Chapter 2 ActionScript Language Reference ...
Page 1104: ...1104 Appendix Deprecated Language Elements ...