Packageflash.text
Classpublic class TextField
InheritanceTextField Inheritance InteractiveObject Inheritance DisplayObject Inheritance EventDispatcher Inheritance Object
Subclasses FlexTextField

The TextField class is used to create display objects for text display and input. All dynamic and input text fields in a SWF file are instances of the TextField class. You can use the TextField class to perform low-level text rendering. However, in Flex, you typically use the Label, Text, TextArea, and TextInput controls to process text.

To create a text field dynamically, use the TextField() constructor.

The methods of the TextField class let you set, select, and manipulate text in a dynamic or input text field that you create during authoring or at runtime.

ActionScript provides several ways to format your text at runtime. The TextFormat class lets you set character and paragraph formatting for TextField objects. You can apply Cascading Style Sheets (CSS) styles to text fields by using the TextField.styleSheet property and the StyleSheet class. You can use CSS to style built-in HTML tags, define new formatting tags, or apply styles. You can assign HTML formatted text, which might optionally use CSS styles, directly to a text field. HTML text that you assign to a text field can contain embedded media (movie clips, SWF files, GIF files, PNG files, and JPEG files). The text wraps around the embedded media in the same way that a web browser wraps text around media embedded in an HTML document.

Flash Player supports a subset of HTML tags that you can use to format text. See the list of supported HTML tags in the description of the htmlText property.

View the examples

See also

flash.text.TextFormat
flash.text.StyleSheet
Core display classes
Basics of working with text


Public Properties
 PropertyDefined By
 InheritedaccessibilityProperties : AccessibilityProperties
The current accessibility options for this display object.
DisplayObject
 Inheritedalpha : Number
Indicates the alpha transparency value of the object specified.
DisplayObject
  alwaysShowSelection : Boolean
When set to true and the text field is not in focus, Flash Player highlights the selection in the text field in gray.
TextField
  antiAliasType : String
The type of anti-aliasing used for this text field.
TextField
  autoSize : String
Controls automatic sizing and alignment of text fields.
TextField
  background : Boolean
Specifies whether the text field has a background fill.
TextField
  backgroundColor : uint
The color of the text field background.
TextField
 InheritedblendMode : String
A value from the BlendMode class that specifies which blend mode to use.
DisplayObject
  border : Boolean
Specifies whether the text field has a border.
TextField
  borderColor : uint
The color of the text field border.
TextField
  bottomScrollV : int
[read-only] An integer (1-based index) that indicates the bottommost line that is currently visible in the specified text field.
TextField
 InheritedcacheAsBitmap : Boolean
If set to true, Flash Player or Adobe AIR caches an internal bitmap representation of the display object.
DisplayObject
  caretIndex : int
[read-only] The index of the insertion point (caret) position.
TextField
  condenseWhite : Boolean
A Boolean value that specifies whether extra white space (spaces, line breaks, and so on) in a text field with HTML text should be removed.
TextField
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  contextMenu : NativeMenu
[read-only]
TextField
  defaultTextFormat : TextFormat
Specifies the format applied to newly inserted text, such as text inserted with the replaceSelectedText() method or text entered by a user.
TextField
  displayAsPassword : Boolean
Specifies whether the text field is a password text field.
TextField
 InheriteddoubleClickEnabled : Boolean
Specifies whether the object receives doubleClick events.
InteractiveObject
  embedFonts : Boolean
Specifies whether to render by using embedded font outlines.
TextField
 Inheritedfilters : Array
An indexed array that contains each filter object currently associated with the display object.
DisplayObject
 InheritedfocusRect : Object
Specifies whether this object displays a focus rectangle.
InteractiveObject
  gridFitType : String
The type of grid fitting used for this text field.
TextField
 Inheritedheight : Number
Indicates the height of the display object, in pixels.
DisplayObject
  htmlText : String
Contains the HTML representation of the text field's contents.
TextField
  length : int
[read-only] The number of characters in a text field.
TextField
 InheritedloaderInfo : LoaderInfo
[read-only] Returns a LoaderInfo object containing information about loading the file to which this display object belongs.
DisplayObject
 Inheritedmask : DisplayObject
The calling display object is masked by the specified mask object.
DisplayObject
  maxChars : int
The maximum number of characters that the text field can contain, as entered by a user.
TextField
  maxScrollH : int
[read-only] The maximum value of scrollH.
TextField
  maxScrollV : int
[read-only] The maximum value of scrollV.
TextField
 InheritedmouseEnabled : Boolean
Specifies whether this object receives mouse messages.
InteractiveObject
  mouseWheelEnabled : Boolean
A Boolean value that indicates whether Flash Player should automatically scroll multiline text fields when the user clicks a text field and rolls the mouse wheel.
TextField
 InheritedmouseX : Number
[read-only] Indicates the x coordinate of the mouse position, in pixels.
DisplayObject
 InheritedmouseY : Number
[read-only] Indicates the y coordinate of the mouse position, in pixels.
DisplayObject
  multiline : Boolean
Indicates whether the text field is a multiline text field.
TextField
 Inheritedname : String
Indicates the instance name of the DisplayObject.
DisplayObject
  numLines : int
[read-only] Defines the number of text lines in a multiline text field.
TextField
 InheritedopaqueBackground : Object
Specifies whether the display object is opaque with a certain background color.
DisplayObject
 Inheritedparent : DisplayObjectContainer
[read-only] Indicates the DisplayObjectContainer object that contains this display object.
DisplayObject
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  restrict : String
Indicates the set of characters that a user can enter into the text field.
TextField
 Inheritedroot : DisplayObject
[read-only] For a display object in a loaded SWF file, the root property is the top-most display object in the portion of the display list's tree structure represented by that SWF file.
DisplayObject
 Inheritedrotation : Number
Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation.
DisplayObject
 Inheritedscale9Grid : Rectangle
The current scaling grid that is in effect.
DisplayObject
 InheritedscaleX : Number
Indicates the horizontal scale (percentage) of the object as applied from the registration point.
DisplayObject
 InheritedscaleY : Number
Indicates the vertical scale (percentage) of an object as applied from the registration point of the object.
DisplayObject
  scrollH : int
The current horizontal scrolling position.
TextField
 InheritedscrollRect : Rectangle
The scroll rectangle bounds of the display object.
DisplayObject
  scrollV : int
The vertical position of text in a text field.
TextField
  selectable : Boolean
A Boolean value that indicates whether the text field is selectable.
TextField
  selectionBeginIndex : int
[read-only] The zero-based character index value of the first character in the current selection.
TextField
  selectionEndIndex : int
[read-only] The zero-based character index value of the last character in the current selection.
TextField
  sharpness : Number
The sharpness of the glyph edges in this text field.
TextField
 Inheritedstage : Stage
[read-only] The Stage of the display object.
DisplayObject
  styleSheet : StyleSheet
Attaches a style sheet to the text field.
TextField
 InheritedtabEnabled : Boolean
Specifies whether this object is in the tab order.
InteractiveObject
 InheritedtabIndex : int
Specifies the tab ordering of objects in a SWF file.
InteractiveObject
  text : String
A string that is the current text in the text field.
TextField
  textColor : uint
The color of the text in a text field, in hexadecimal format.
TextField
  textHeight : Number
[read-only] The height of the text in pixels.
TextField
  textWidth : Number
[read-only] The width of the text in pixels.
TextField
  thickness : Number
The thickness of the glyph edges in this text field.
TextField
 Inheritedtransform : Transform
An object with properties pertaining to a display object's matrix, color transform, and pixel bounds.
DisplayObject
  type : String
The type of the text field.
TextField
  useRichTextClipboard : Boolean
Specifies whether to copy and paste the text formatting along with the text.
TextField
 Inheritedvisible : Boolean
Whether or not the display object is visible.
DisplayObject
 Inheritedwidth : Number
Indicates the width of the display object, in pixels.
DisplayObject
  wordWrap : Boolean
A Boolean value that indicates whether the text field has word wrap.
TextField
 Inheritedx : Number
Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent DisplayObjectContainer.
DisplayObject
 Inheritedy : Number
Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent DisplayObjectContainer.
DisplayObject
Public Methods
 MethodDefined By
  
Creates a new TextField instance.
TextField
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
  
Appends the string specified by the newText parameter to the end of the text of the text field.
TextField
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
getBounds(targetCoordinateSpace:DisplayObject):Rectangle
Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object.
DisplayObject
  
Returns a rectangle that is the bounding box of the character.
TextField
  
Returns the zero-based index value of the character at the point specified by the x and y parameters.
TextField
  
Given a character index, returns the index of the first character in the same paragraph.
TextField
  
Returns a DisplayObject reference for the given id, for an image or SWF file that has been added to an HTML-formatted text field by using an <img> tag.
TextField
  
Returns the zero-based index value of the line at the point specified by the x and y parameters.
TextField
  
Returns the zero-based index value of the line containing the character specified by the charIndex parameter.
TextField
  
getLineLength(lineIndex:int):int
Returns the number of characters in a specific text line.
TextField
  
Returns metrics information about a given text line.
TextField
  
getLineOffset(lineIndex:int):int
Returns the character index of the first character in the line that the lineIndex parameter specifies.
TextField
  
getLineText(lineIndex:int):String
Returns the text of the line specified by the lineIndex parameter.
TextField
  
Given a character index, returns the length of the paragraph containing the given character.
TextField
 Inherited
getRect(targetCoordinateSpace:DisplayObject):Rectangle
Returns a rectangle that defines the boundary of the display object, based on the coordinate system defined by the targetCoordinateSpace parameter, excluding any strokes on shapes.
DisplayObject
  
getTextFormat(beginIndex:int = -1, endIndex:int = -1):TextFormat
Returns a TextFormat object that contains formatting information for the range of text that the beginIndex and endIndex parameters specify.
TextField
 Inherited
Converts the point object from the Stage (global) coordinates to the display object's (local) coordinates.
DisplayObject
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Evaluates the display object to see if it overlaps or intersects with the obj display object.
DisplayObject
 Inherited
hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean
Evaluates the display object to see if it overlaps or intersects with the point specified by the x and y parameters.
DisplayObject
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates.
DisplayObject
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
  
Replaces the current selection with the contents of the value parameter.
TextField
  
replaceText(beginIndex:int, endIndex:int, newText:String):void
Replaces the range of characters that the beginIndex and endIndex parameters specify with the contents of the newText parameter.
TextField
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
  
setSelection(beginIndex:int, endIndex:int):void
Sets as selected the text designated by the index values of the first and last characters, which are specified with the beginIndex and endIndex parameters.
TextField
  
setTextFormat(format:TextFormat, beginIndex:int = -1, endIndex:int = -1):void
Applies the text formatting that the format parameter specifies to the specified text in a text field.
TextField
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 Event Summary Defined By
 Inherited Dispatched when Flash Player or an AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited Dispatched when a display object is added to the display list.DisplayObject
 Inherited Dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained.DisplayObject
   Dispatched after a control's value is modified.TextField
 Inherited Dispatched when a user presses and releases the main button of the user's pointing device over the same InteractiveObject.InteractiveObject
 Inherited Dispatched when the user selects the context menu associated with this interactive object in an AIR application.InteractiveObject
 Inherited Dispatched when Flash Player or an AIR application loses operating system focus and is becoming inactive.EventDispatcher
 Inherited Dispatched when a user presses and releases the main button of a pointing device twice in rapid succession over the same InteractiveObject when that object's doubleClickEnabled flag is set to true.InteractiveObject
 Inherited Dispatched when the playhead is entering a new frame.DisplayObject
 Inherited Dispatched after a display object gains focus.InteractiveObject
 Inherited Dispatched after a display object loses focus.InteractiveObject
 Inherited Dispatched when the user presses a key.InteractiveObject
 Inherited Dispatched when the user attempts to change focus by using keyboard navigation.InteractiveObject
 Inherited Dispatched when the user releases a key.InteractiveObject
   Dispatched when a user clicks a hyperlink in an HTML-enabled text field, where the URL begins with "event:".TextField
 Inherited Dispatched when a user presses and releases the middle button of the user's pointing device over the same InteractiveObject.InteractiveObject
 Inherited Dispatched when a user presses the middle pointing device button over an InteractiveObject instance.InteractiveObject
 Inherited Dispatched when a user releases the pointing device button over an InteractiveObject instance.InteractiveObject
 Inherited Dispatched when a user presses the pointing device button over an InteractiveObject instance.InteractiveObject
 Inherited Dispatched when the user attempts to change focus by using a pointer device.InteractiveObject
 Inherited Dispatched when a user moves the pointing device while it is over an InteractiveObject.InteractiveObject
 Inherited Dispatched when the user moves a pointing device away from an InteractiveObject instance.InteractiveObject
 Inherited Dispatched when the user moves a pointing device over an InteractiveObject instance.InteractiveObject
 Inherited Dispatched when a user releases the pointing device button over an InteractiveObject instance.InteractiveObject
 Inherited Dispatched when a mouse wheel is spun over an InteractiveObject instance.InteractiveObject
 Inherited Dispatched by the drag initiator InteractiveObject when the user releases the drag gesture.InteractiveObject
 Inherited Dispatched by the target InteractiveObject when a dragged object is dropped on it and the drop has been accepted with a call to DragManager.acceptDragDrop().InteractiveObject
 Inherited Dispatched by an InteractiveObject when a drag gesture enters its boundary.InteractiveObject
 Inherited Dispatched by an InteractiveObject when a drag gesture leaves its boundary.InteractiveObject
 Inherited Dispatched by an InteractiveObject continually while a drag gesture remains within its boundary.InteractiveObject
 Inherited Dispatched at the beginning of a drag operation by the InteractiveObject that is specified as the drag initiator in the DragManager.doDrag() call.InteractiveObject
 Inherited Dispatched during a drag operation by the InteractiveObject that is specified as the drag initiator in the DragManager.doDrag() call.InteractiveObject
 Inherited Dispatched when a display object is about to be removed from the display list.DisplayObject
 Inherited Dispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained.DisplayObject
 Inherited Dispatched when the display list is about to be updated and rendered.DisplayObject
 Inherited Dispatched when a user presses and releases the right button of the user's pointing device over the same InteractiveObject.InteractiveObject
 Inherited Dispatched when a user presses the pointing device button over an InteractiveObject instance.InteractiveObject
 Inherited Dispatched when a user releases the pointing device button over an InteractiveObject instance.InteractiveObject
 Inherited Dispatched when the user moves a pointing device away from an InteractiveObject instance.InteractiveObject
 Inherited Dispatched when the user moves a pointing device over an InteractiveObject instance.InteractiveObject
   Dispatched by a TextField object after the user scrolls.TextField
 Inherited Dispatched when the value of the object's tabChildren flag changes.InteractiveObject
 Inherited Dispatched when the object's tabEnabled flag changes.InteractiveObject
 Inherited Dispatched when the value of the object's tabIndex property changes.InteractiveObject
   Flash Player dispatches the textInput event when a user enters one or more characters of text.TextField
Property Detail
alwaysShowSelectionproperty
alwaysShowSelection:Boolean  [read-write]

When set to true and the text field is not in focus, Flash Player highlights the selection in the text field in gray. When set to false and the text field is not in focus, Flash Player does not highlight the selection in the text field.

The default value is false.


Implementation
    public function get alwaysShowSelection():Boolean
    public function set alwaysShowSelection(value:Boolean):void

See also


Example

Compile and run the following file. When you run the file, drag to select text in each of the two text fields, and notice the difference in selection highlighting when you select text in the two text fields (changing focus):

    package {
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFieldType;

    public class TextField_alwaysShowSelection extends Sprite {
        public function TextField_alwaysShowSelection() {
            var label1:TextField = createTextField(0, 20, 200, 20);
            label1.text = "This text is selected.";
            label1.setSelection(0, 9);
            label1.alwaysShowSelection = true;

            var label2:TextField = createTextField(0, 50, 200, 20);
            label2.text = "Drag to select some of this text.";
        }

        private function createTextField(x:Number, y:Number, width:Number, height:Number):TextField {
            var result:TextField = new TextField();
            result.x = x; result.y = y;
            result.width = width; result.height = height;
            addChild(result);
            return result;
        }
    }
}
antiAliasTypeproperty 
antiAliasType:String  [read-write]

The type of anti-aliasing used for this text field. Use flash.text.AntiAliasType constants for this property. You can control this setting only if the font is embedded (with the embedFonts property set to true). The default setting is flash.text.AntiAliasType.NORMAL.

To set values for this property, use the following string values:

String valueDescription
flash.text.AntiAliasType.NORMALApplies the regular text anti-aliasing. This matches the type of anti-aliasing that Flash Player 7 and earlier versions used.
flash.text.AntiAliasType.ADVANCEDApplies advanced anti-aliasing, which makes text more legible. (This feature became available in Flash Player 8.) Advanced anti-aliasing allows for high-quality rendering of font faces at small sizes. It is best used with applications that have a lot of small text. Advanced anti-aliasing is not recommended for fonts that are larger than 48 points.


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

See also

autoSizeproperty 
autoSize:String  [read-write]

Controls automatic sizing and alignment of text fields. Acceptable values for the TextFieldAutoSize constants: TextFieldAutoSize.NONE (the default), TextFieldAutoSize.LEFT, TextFieldAutoSize.RIGHT, and TextFieldAutoSize.CENTER.

If autoSize is set to TextFieldAutoSize.NONE (the default) no resizing occurs.

If autoSize is set to TextFieldAutoSize.LEFT, the text is treated as left-justified text, meaning that the left margin of the text field remains fixed and any resizing of a single line of the text field is on the right margin. If the text includes a line break (for example, "\n" or "\r"), the bottom is also resized to fit the next line of text. If wordWrap is also set to true, only the bottom of the text field is resized and the right side remains fixed.

If autoSize is set to TextFieldAutoSize.RIGHT, the text is treated as right-justified text, meaning that the right margin of the text field remains fixed and any resizing of a single line of the text field is on the left margin. If the text includes a line break (for example, "\n" or "\r"), the bottom is also resized to fit the next line of text. If wordWrap is also set to true, only the bottom of the text field is resized and the left side remains fixed.

If autoSize is set to TextFieldAutoSize.CENTER, the text is treated as center-justified text, meaning that any resizing of a single line of the text field is equally distributed to both the right and left margins. If the text includes a line break (for example, "\n" or "\r"), the bottom is also resized to fit the next line of text. If wordWrap is also set to true, only the bottom of the text field is resized and the left and right sides remain fixed.


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

Throws
ArgumentError — The autoSize specified is not a member of flash.text.TextFieldAutoSize.

See also

backgroundproperty 
background:Boolean  [read-write]

Specifies whether the text field has a background fill. If true, the text field has a background fill. If false, the text field has no background fill. Use the backgroundColor property to set the background color of a text field.

The default value is false.


Implementation
    public function get background():Boolean
    public function set background(value:Boolean):void

See also

backgroundColorproperty 
backgroundColor:uint  [read-write]

The color of the text field background. The default value is 0xFFFFFF (white). This property can be retrieved or set, even if there currently is no background, but the color is visible only if the text field has the background property set to true.


Implementation
    public function get backgroundColor():uint
    public function set backgroundColor(value:uint):void

See also

borderproperty 
border:Boolean  [read-write]

Specifies whether the text field has a border. If true, the text field has a border. If false, the text field has no border. Use the borderColor property to set the border color.

The default value is false.


Implementation
    public function get border():Boolean
    public function set border(value:Boolean):void

See also

borderColorproperty 
borderColor:uint  [read-write]

The color of the text field border. The default value is 0x000000 (black). This property can be retrieved or set, even if there currently is no border, but the color is visible only if the text field has the border property set to true.


Implementation
    public function get borderColor():uint
    public function set borderColor(value:uint):void

See also

bottomScrollVproperty 
bottomScrollV:int  [read-only]

An integer (1-based index) that indicates the bottommost line that is currently visible in the specified text field. Think of the text field as a window onto a block of text. The scrollV property is the 1-based index of the topmost visible line in the window.

All the text between the lines indicated by scrollV and bottomScrollV is currently visible in the text field.


Implementation
    public function get bottomScrollV():int

See also

caretIndexproperty 
caretIndex:int  [read-only]

The index of the insertion point (caret) position. If no insertion point is displayed, the value is the position the insertion point would be if you restored focus to the field (typically where the insertion point last was, or 0 if the field has not had focus).

Selection span indexes are zero-based (for example, the first position is 0, the second position is 1, and so on).


Implementation
    public function get caretIndex():int

See also


Example

In this example, a TextField instance is created and populated with text. An event listener is assigned so that when the user clicks on the TextField, the printCursorPosition method is called. In that case, the values of the caretIndex, selectionBeginIndex, and selectionEndIndex properties are output.

Run this example and try clicking in the TextField to select text. Then click in the field without selecting text. When you click in the text without making a selection, the caretIndex property indicates where the insertion point occurs, and the selectionBeginIndex and selectionEndIndex properties equal the caretIndex property value.


package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldType;

    public class TextField_caretIndex extends Sprite {
        public function TextField_caretIndex() {
            var tf:TextField = createTextField(10, 10, 100, 100);
            tf.wordWrap = true;
            tf.type = TextFieldType.INPUT;
            tf.text = "Click in this text field. Compare the difference between clicking without selecting versus clicking and selecting text.";
            tf.addEventListener(MouseEvent.CLICK, printCursorPosition);
        }

        private function printCursorPosition(event:MouseEvent):void {
            var tf:TextField = TextField(event.target);
            trace("caretIndex:", tf.caretIndex);
            trace("selectionBeginIndex:", tf.selectionBeginIndex);
            trace("selectionEndIndex:", tf.selectionEndIndex);
        }

        private function createTextField(x:Number, y:Number, width:Number, height:Number):TextField {
            var result:TextField = new TextField();
            result.x = x;
            result.y = y;
            result.width = width;
            result.height = height;
            addChild(result);
            return result;
        }
    }
}
condenseWhiteproperty 
condenseWhite:Boolean  [read-write]

A Boolean value that specifies whether extra white space (spaces, line breaks, and so on) in a text field with HTML text should be removed. The default value is false. The condenseWhite property only affects text set with the htmlText property, not the text property. If you set text with the text property, condenseWhite is ignored.

If you set condenseWhite to true, you must use standard HTML commands such as <BR> and <P> to place line breaks in the text field.

Set the condenseWhite property before setting the htmlText property.


Implementation
    public function get condenseWhite():Boolean
    public function set condenseWhite(value:Boolean):void

See also


Example

The following shows the difference between setting the condenseWhite setting to false and setting it to true:

package {
    import flash.display.Sprite;
    import flash.text.TextField;

    public class TextField_condenseWhite extends Sprite {
        public function TextField_condenseWhite() {
            var tf1:TextField = createTextField(0, 0, 200, 50);
            tf1.condenseWhite = false;
            tf1.htmlText = "keep    on\n\ttruckin'";
            
            var tf2:TextField = createTextField(0, 120, 200, 50);
            tf2.condenseWhite = true;
            tf2.htmlText = "keep    on\n\ttruckin'";
        }

        private function createTextField(x:Number, y:Number, width:Number, height:Number):TextField {
            var result:TextField = new TextField();
            result.x = x;
            result.y = y;
            result.width = width;
            result.height = height;
            result.border = true;
            addChild(result);
            return result;
        }
    }
}
contextMenuproperty 
contextMenu:NativeMenu  [read-only]
Implementation
    public function get contextMenu():NativeMenu
defaultTextFormatproperty 
defaultTextFormat:TextFormat  [read-write]

Specifies the format applied to newly inserted text, such as text inserted with the replaceSelectedText() method or text entered by a user.

When you access the defaultTextFormat property, the returned TextFormat object has all of its properties defined. No property is null.

Note: You can't set this property if a style sheet is applied to the text field.


Implementation
    public function get defaultTextFormat():TextFormat
    public function set defaultTextFormat(value:TextFormat):void

Throws
Error — This method cannot be used on a text field with a style sheet.

See also

displayAsPasswordproperty 
displayAsPassword:Boolean  [read-write]

Specifies whether the text field is a password text field. If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field. When password mode is enabled, the Cut and Copy commands and their corresponding keyboard shortcuts will not function. This security mechanism prevents an unscrupulous user from using the shortcuts to discover a password on an unattended computer.

The default value is false.


Implementation
    public function get displayAsPassword():Boolean
    public function set displayAsPassword(value:Boolean):void
embedFontsproperty 
embedFonts:Boolean  [read-write]

Specifies whether to render by using embedded font outlines. If false, Flash Player renders the text field by using device fonts.

If you set the embedFonts property to true for a text field, you must specify a font for that text by using the font property of a TextFormat object applied to the text field. If the specified font is not embedded in the SWF file, the text is not displayed.

The default value is false.


Implementation
    public function get embedFonts():Boolean
    public function set embedFonts(value:Boolean):void

See also

gridFitTypeproperty 
gridFitType:String  [read-write]

The type of grid fitting used for this text field. This property applies only if the flash.text.AntiAliasType property of the text field is set to flash.text.AntiAliasType.ADVANCED.

The type of grid fitting used determines whether Flash Player forces strong horizontal and vertical lines to fit to a pixel or subpixel grid, or not at all.

For the flash.text.GridFitType property, you can use the following string values:

String valueDescription