TextField.wordWrap Property

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

enable automatic line-breaking for long lines read/write
theField.wordWrap

Description

The Boolean wordWrap property enables (true) or disables (false) automatic line-breaking in theField. It applies to both user input and text assigned programmatically, and it defaults to false. When word-wrapping is enabled, long lines of text soft wrap that is, any line that is wider than theField's bounding box will automatically flow onto the following line. This is a display feature only; no carriage return or newline character appears in the source text where wrapping occurs. When wrapping is disabled, text on long lines flows beyond theField's bounding box and part of the line is hidden. If wordWrap is true, changing the field's _width causes long lines to soft wrap at a different point (i.e., the text reflows). Hard returns can be added to a text field using the \n escape sequence or newline constant.

Bugs

In Flash 6, the wordWrap property must be set before any text is assigned to the text field; otherwise, wrapping may not be applied. For example:

// Set word wrap first theField_txt.wordWrap = true; // Now assign text theField_txt.text = "This is a fairly long line so it might wrap when displayed.";

Example

To create a typical multi-paragraph text entry box for user input, set both wordWrap and multiline to true. For example,

this.createTextField("theField_txt", 1, 0, 0, 200, 100); theField_txt.type = "input"; theField_txt.border = true; theField_txt.wordWrap = true; theField_txt.multiline = true; theField_txt.text = "Type input here.";

See Also

TextField.multiline, TextField._width



    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