The TextFormat class represents character formatting information. Use the TextFormat class
to create specific text formatting for text fields. You can apply text formatting
to both static and dynamic text fields. The properties of the TextFormat class apply to device and
embedded fonts. However, for embedded fonts, bold and italic text actually require specific fonts. If you
want to display bold or italic text with an embedded font, you need to embed the bold and italic variations
of that font.

You must use the constructor new TextFormat() to create a TextFormat object
before setting its properties.
When you apply a TextFormat object to a text field using the TextField.defaultTextFormat property
or the TextField.setTextFormat() method, only its defined properties are applied. Use
the TextField.defaultTextFormat property to apply formatting BEFORE you add text to the TextField,
and the setTextFormat() method to add formatting AFTER you add text to the TextField.
The TextFormat properties are null by default
because if you don't provide values for the properties, Flash Player uses its own default formatting.
The default formatting that Flash Player uses for each property (if property's value is null)
is as follows:

align = "left"

blockIndent = 0

bold = false

bullet = false

color = 0x000000

font = "Times New Roman" (default font is Times on Mac OS X)

indent = 0

italic = false

kerning = false

leading = 0

leftMargin = 0

letterSpacing = 0

rightMargin = 0

size = 12

tabStops = [] (empty array)

target = "" (empty string)

underline = false

url = "" (empty string)

The default formatting for each property is also described in each property description.

blockIndent

Indicates the block indentation in pixels. Block indentation is applied to
an entire block of text; that is, to all lines of the text. In contrast, normal indentation
(TextFormat.indent) affects only the first line of each paragraph.
If this property is null, the TextFormat object does not specify block indentation
(block indentation is 0).

Implementation public function get blockIndent():Object public function set blockIndent(value:Object):void

bullet

Indicates that the text is part of a bulleted list. In a bulleted
list, each paragraph of text is indented. To the left of the first line of each paragraph, a bullet
symbol is displayed. The default value is null, which means no bulleted list
is used.

Implementation public function get bullet():Object public function set bullet(value:Object):void

color

Indicates the color of the text. A number containing three 8-bit RGB components; for example,
0xFF0000 is red, and 0x00FF00 is green. The default value is null,
which means that Flash Player uses the color black (0x000000).

Implementation public function get color():Object public function set color(value:Object):void

kerning

A Boolean value that indicates whether kerning is enabled (true)
or disabled (false). Kerning adjusts the pixels between certain character pairs to improve readability, and
should be used only when necessary, such as with headings in large fonts. Kerning is
supported for embedded fonts only.

Certain fonts such as Verdana and monospaced fonts,
such as Courier New, do not support kerning.

The default value is null, which means that kerning is not enabled.

Implementation public function get kerning():Object public function set kerning(value:Object):void

letterSpacing

A number representing the amount of space that is uniformly distributed between all characters.
The value specifies the number of pixels that are added to the advance after each character.
The default value is null, which means that 0 pixels of letter spacing is used.
You can use decimal values such as 1.75.

Implementation public function get letterSpacing():Object public function set letterSpacing(value:Object):void

tabStops

Specifies custom tab stops as an array of non-negative integers. Each tab stop is
specified in pixels. If custom tab stops are not specified (null), the default tab
stop is 4 (average character width).

Implementation public function get tabStops():Array public function set tabStops(value:Array):void

target

Indicates the target window where the hyperlink is displayed. If the target window is an
empty string, the text is displayed in the default target window _self. You can choose
a custom name or one of the following four names: _self specifies the current frame in
the current window, _blank specifies a new window, _parent specifies the
parent of the current frame, and _top specifies the top-level frame in the current
window. If the TextFormat.url property is an empty string or null,
you can get or set this property, but the property will have no effect.

Implementation public function get target():String public function set target(value:String):void

underline

Indicates whether the text that uses this text format is underlined (true)
or not (false). This underlining is similar to that produced by the
<U> tag, but the latter is not true underlining, because it does not skip
descenders correctly. The default value is null, which indicates that underlining
is not used.

Implementation public function get underline():Object public function set underline(value:Object):void

url

Indicates the target URL for the text in this text format. If the url
property is an empty string, the text does not have a hyperlink. The default value is null,
which indicates that the text does not have a hyperlink.

Note: The text with the assigned text format must be set with the htmlText
property for the hyperlink to work.

Implementation public function get url():String public function set url(value:String):void

url:String (default = null) — The URL to which the text in this text format hyperlinks. If url is
an empty string, the text does not have a hyperlink.

target:String (default = null) — The target window where the hyperlink is displayed. If the target window is an empty
string, the text is displayed in the default target window _self. If the
url parameter is set to an empty string or to the value null, you can get or
set this property, but the property will have no effect.

align:String (default = null) — The alignment of the paragraph, as a TextFormatAlign value.

leftMargin:Object (default = null) — Indicates the left margin of the paragraph, in pixels.

rightMargin:Object (default = null) — Indicates the right margin of the paragraph, in pixels.

indent:Object (default = null) — An integer that indicates the indentation from the left margin to the first character
in the paragraph.

leading:Object (default = null) — A number that indicates the amount of leading vertical space between lines.

In the following example, a user can select different text formatting
options from a list that is applied to the content of another text field. If the user
clicks on the text field's content, the formatting reverts to the default (original) format.

The formatTextField text field lists all the TextField class property options
(with the exception of kerning) in a separate line. When a user clicks a
line in the formatTextField text field, the formatTextFieldClickHandler()
method is triggered.

The formatTextFieldClickHandler() method calls the TextField.getLineIndexAtPoint()
method to get the index of the line that was clicked, and then calls the TextField.getLineText()
method to get the content of the line. The switch statement checks the content of the line and sets
a property of the newformat TextFormat object accordingly. The setTextFormat()
method then sets the text format of the contentTextField text field to the new format. By clicking
different formatTextField lines, a user can apply a different formatting
to the contentTextField text field. (The tab setting is an array that defines
a separate tab stop for each tab in the line.) If the url or target line
is selected, the user must click the contentTextField text field to activate the link
and display the content of the target URL (Flex home page). The default value of the target
property is "_self", which means that the content is displayed in the current window if the user
selects the url line. For the target property to work, a URL must be
set already in the url property.

If a user clicks the contentTextField text field, the contentTextFieldClickHandler()
method is triggered, which sets the field's format and the newFormat TextFormat
object to the default (original) format of the text field. This clears all the formatting changes
that the user made.

The following example creates the TextFieldExample class to display a text message with
the default location (x = 0, y = 0). This is accomplished using the following steps:

A property label of type TextField is created.

The class constructor calls the function configureLabel()

The configureLabel() function first creates a new TextField object and assigns it to
label then sets its parameters to

Left-justify the text field

Enable the background fill

Enable the border.

Next, configureLabel() creates the local variable, format, and assigns it to
a new TextFormat instance with its parameters set to:

Font type = Verdana

Font Color = solid red

Font size = 10

Font underline = true.

The label's defaultTextFormat property is set to format, and the
label instance is added to the display list, which initially displays a text field with
no text (as tiny box with a white background) on the stage.

Finally (back in the constructor), the label's text is then set to display "Hello
World and welcome to the show", at coordinates x = 0, y = 0 by calling setLabel().