Table of Contents

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


Table of Contents