TextField._width Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
TextField._width Property Flash 6

width of the text field's bounding box, in pixels read/write
theField._width

Description

Every text field implicitly defines a rectangular region, known as its bounding box, inside which text is displayed. The floating-point _width property is a nonnegative number specifying the width of a field's bounding box, in pixels. By changing _width, we resize the field's bounding box, allowing it to display more or less text. Changing a field's _width does not also affect the width of the text it contains; to change the text's point size, use a TextFormat object or the _yscale property. To check the width of a field's text, use textWidth. Note that in Flash 6, the autoSize property can be used to force a text field's bounding box to fit its text.

Changes made to a text field's width in the authoring tool or via _xscale are reflected by _width. To apply a stroke or a fill to a field's bounding box, use the border and background properties.

Example

// Set initial width to 200 this.createTextField("theField_txt", 1, 0, 0, 200, 20); theField_txt.border = true; theField_txt.text = "Room to grow!"; // Set the bounding box width to twice the width of the text in the field theField_txt._width = theField_txt.textWidth * 2;

See Also

TextField.autoSize, TextField._height, TextField.textWidth, TextField.wordWrap, TextField._xscale, the TextFormat class



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net