Options
Menu

Class TextFormat

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:

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

Hierarchy

  • AssetBase

Implements

  • IAsset
  • IAssetAdapter

Index

Constructors

constructor

  • new TextFormat(font?: string, size?: number, color?: number, bold?: boolean, italic?: boolean, underline?: boolean, url?: string, link_target?: string, align?: string, leftMargin?: number, rightMargin?: number, indent?: number, leading?: number): TextFormat
  • Creates a TextFormat object with the specified properties. You can then change the properties of the TextFormat object to change the formatting of text fields.

    Any parameter may be set to null to indicate that it is not defined. All of the parameters are optional; any omitted parameters are treated as null.

    Parameters

    • Default value font: string = "Times New Roman"

      The name of a font for text as a string.

    • Default value size: number = 12

      An integer that indicates the size in pixels.

    • Default value color: number = 0

      The color of text using this text format. A number containing three 8-bit RGB components; for example, 0xFF0000 is red, and 0x00FF00 is green.

    • Default value bold: boolean = false

      A Boolean value that indicates whether the text is boldface.

    • Default value italic: boolean = false

      A Boolean value that indicates whether the text is italicized.

    • Default value underline: boolean = false

      A Boolean value that indicates whether the text is underlined.

    • Default value url: string = ""

      The URL to which the text in this text format hyperlinks. If url is an empty string, the text does not have a hyperlink.

    • Default value link_target: string = ""
    • Default value align: string = "left"

      The alignment of the paragraph, as a TextFormatAlign value.

    • Default value leftMargin: number = 0

      Indicates the left margin of the paragraph, in pixels.

    • Default value rightMargin: number = 0

      Indicates the right margin of the paragraph, in pixels.

    • Default value indent: number = 0

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

    • Default value leading: number = 0

      A number that indicates the amount of leading vertical space between lines.

    Returns TextFormat

Properties

_adapter

_adapter: IAssetAdapter

adaptee

adaptee: AssetBase

adapter

adapter: IAssetAdapter

adapter is used to provide MovieClip to scripts taken from different platforms setter typically managed by factory. getter defaults to AwayJS class

align

align: string

Indicates the alignment of the paragraph. Valid values are TextFormatAlign constants.

default

TextFormatAlign.LEFT

throws

ArgumentError The align specified is not a member of flash.text.TextFormatAlign.

assetFullPath

assetFullPath: Array<string>

assetNamespace

assetNamespace: string

blockIndent

blockIndent: number

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).

bold

bold: boolean

Specifies whether the text is boldface. The default value is null, which means no boldface is used. If the value is true, then the text is boldface.

bullet

bullet: boolean

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.

color

color: number

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).

fallback_font_table

fallback_font_table: IFontTable

The font-table that provides the subgeos for the chars

font

font: string

font_name

font_name: string

The name of the font for text in this text format, as a string. To be valid, for use with curve-rendering, the textFormat must have a Font-table assigned. The font-name can be used to get a Font-object from the AssetLibrary. A Font object provides a list of Font-table, corresponding to font-table names.

font_style

font_style: string

The name of the font-style for text in this text format, as a string. To be valid, for use with curve-rendering, the textFormat must have a Font-table assigned. The font-style can be used to get a Font-table, from a Font-object.

font_table

font_table: IFontTable

The font-table that provides the subgeos for the chars

id

id: number

A unique id for the asset, used to identify assets in an associative array

indent

indent: number

Indicates the indentation from the left margin to the first character in the paragraph. The default value is null, which indicates that no indentation is used.

italic

italic: boolean

Indicates whether text in this text format is italicized. The default value is null, which means no italics are used.

kerning

kerning: boolean

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.

leading

leading: number

An integer representing the amount of vertical space(called leading) between lines. The default value is null, which indicates that the amount of leading used is 0.

leftMargin

leftMargin: number

The left margin of the paragraph, in pixels. The default value is null, which indicates that the left margin is 0 pixels.

letterSpacing

letterSpacing: number

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.

link_target

link_target: string

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.

material

material: MaterialBase

The material to use for texturing geometry generated for this text-format. this material will be used by the TextField

name

name: string

originalName

originalName: string

The original name used for this asset in the resource (e.g. file) in which it was found. This may not be the same as name, which may have changed due to of a name conflict.

rightMargin

rightMargin: number

The right margin of the paragraph, in pixels. The default value is null, which indicates that the right margin is 0 pixels.

tabStops

tabStops: Array<number>

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).

underline

underline: boolean

Indicates whether the text that uses this text format is underlined (true) or not(false). This underlining is similar to that produced by the 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.

url

url: string

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.

uv_values

uv_values: Array<number>

The uv-values of the colors in textureatlas. The lenght migth be 4 in future to support bitmap-fills and gradients, but for now it will should always be 2

Static DEFAULT_NAMESPACE

DEFAULT_NAMESPACE: string

Static ID_COUNT

ID_COUNT: number

Static assetType

assetType: string

Accessors

assetType

  • get (): string
  • Returns string

size

  • get (): number
  • set (value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

Methods

addEventListener

  • addEventListener(type: string, listener: function): void
  • Add an event listener

    method

    addEventListener

    Parameters

    • type: string
    • listener: function
        • (event: EventBase): void
        • Parameters

          • event: EventBase

          Returns void

    Returns void

assetPathEquals

  • assetPathEquals(name: string, ns: string): boolean
  • Parameters

    • name: string
    • ns: string

    Returns boolean

clear

  • clear(): void
  • Returns void

dispatchEvent

  • dispatchEvent(event: EventBase): void
  • Dispatch an event

    method

    dispatchEvent

    Parameters

    • event: EventBase

    Returns void

dispose

  • dispose(): void
  • inheritdoc

    Returns void

hasEventListener

  • hasEventListener(type: string, listener?: function): boolean
  • check if an object has an event listener assigned to it

    method

    hasListener

    Parameters

    • type: string
    • Optional listener: function
        • (event: EventBase): void
        • Parameters

          • event: EventBase

          Returns void

    Returns boolean

invalidate

  • invalidate(): void
  • Returns void

isAsset

  • isAsset(assetClass: IAssetClass): boolean
  • Parameters

    • assetClass: IAssetClass

    Returns boolean

removeEventListener

  • removeEventListener(type: string, listener: function): void
  • Remove an event listener

    method

    removeEventListener

    Parameters

    • type: string
    • listener: function
        • (event: EventBase): void
        • Parameters

          • event: EventBase

          Returns void

    Returns void

resetAssetPath

  • resetAssetPath(name: string, ns?: string, overrideOriginal?: boolean): void
  • Parameters

    • name: string
    • Optional ns: string
    • Optional overrideOriginal: boolean

    Returns void

updateFullPath

  • updateFullPath(): void
  • Returns void

Generated using TypeDoc