TextFormat


Object
    |
    +-TextFormat

public class TextFormat
extends Object

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. Some properties of the TextFormat class are not available for both embedded and device fonts.

You must use the constructor new TextFormat() to create a TextFormat object before calling its methods.

You can set TextFormat parameters to null to indicate that they are undefined. When you apply a TextFormat object to a text field using TextField.setTextFormat(), only its defined properties are applied, as in the following example:

this.createTextField("my_txt", this.getNextHighestDepth(), 0, 0, 100, 22); 
my_txt.autoSize = true; 
my_txt.text = "Lorem ipsum dolor sit amet..."; 

var my_fmt:TextFormat = new TextFormat(); 
my_fmt.bold = true; 
my_txt.setTextFormat(my_fmt); 

This code first creates an empty TextFormat object with all of its properties null, and then sets the bold property to a defined value. The MovieClip.getNextHighestDepth() method used in this example requires Flash Player 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the MovieClip.getNextHighestDepth() method.

The code my_txt.setTextFormat(my_fmt) only changes the bold property of the text field's default text format, because the bold property is the only one defined in my_fmt . All other aspects of the text field's default text format remain unchanged.

When TextField.getTextFormat() is invoked, a TextFormat object is returned with all of its properties defined; no property is null.

Availability: ActionScript 1.0; Flash Player 6

See also

setTextFormat (TextField.setTextFormat method), getTextFormat (TextField.getTextFormat method)

Property summary

Modifiers

Property

Description

 

align:String

A string that indicates the alignment of the paragraph.

 

blockIndent:Number

A number that indicates the block indentation in points.

 

bold:Boolean

A Boolean value that specifies whether the text is boldface.

 

bullet:Boolean

A Boolean value that indicates that the text is part of a bulleted list.

 

color:Number

Indicates the color of text.

 

font:String

The name of the font for text in this text format, as a string.

 

indent:Number

An integer that indicates the indentation from the left margin to the first character in the paragraph.

 

italic:Boolean

A Boolean value that indicates whether text in this text format is italicized.

 

kerning:Boolean

A Boolean value that indicates whether kerning is enabled or disabled.

 

leading:Number

An integer that represents the amount of vertical space in pixels (called leading) between lines.

 

leftMargin:Number

The left margin of the paragraph, in points.

 

letterSpacing:Number

The amount of space that is uniformly distributed between characters.

 

rightMargin:Number

The right margin of the paragraph, in points.

 

size:Number

The point size of text in this text format.

 

tabStops:Array

Specifies custom tab stops as an array of non-negative integers.

 

target:String

Indicates the target window where the hyperlink is displayed.

 

underline:Boolean

A Boolean value that indicates whether the text that uses this text format is underlined (true) or not (false).

 

url:String

Indicates the URL that text in this text format hyperlinks to.

Properties inherited from class Object

constructor, __proto__, prototype, __resolve


Constructor summary

Signature

Description

TextFormat([font:String], [size:Number], [color:Number], [bold:Boolean], [italic:Boolean], [underline:Boolean], [url:String], [target:String], [align:String], [leftMargin:Number], [rightMargin:Number], [indent:Number], [leading:Number])

Creates a TextFormat object with the specified properties.

Method summary

Modifiers

Signature

Description

 

getTextExtent(text:String, [width:Number]) : Object

Deprecated since Flash Player 8. There is no replacement.

Returns text measurement information for the text string text in the format specified by my_fmt.

Methods inherited from class Object

addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch



Version 8

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00002801.html