8.11. Specifying Wrapping of Multiline Fields

Problem

You want to set the word wrapping setting for a multiline text field or text area.

Solution

If you are using a text area component, set the wordWrap parameter to true.

For a text field, choose the appropriate selection in the Line type menu (see Recipe 8.9 for more information) in order to accomplish this at authoring time. Set the value of the wordWrap property using ActionScript to modify word wrapping at runtime.

Discussion

If you are working with a text area component, the default behavior is that it wraps words. You can toggle the wordWrap parameter on and off, which can be found in the Component Inspector panel. Select the instance on stage, open the Component Inspector panel, and change the value of the wordWrap parameter. A value of true (the default setting) makes the text wrap to the next line if and when it is too long to fit within the horizontal boundaries of the text area. A value of false means that new lines appear only when they have been placed there by way of a newline, carriage return, or form feed character. (In addition, if the text area is configured to render HTML, <p> and <br> tags will cause new lines of text.) Otherwise, the text continues to extend horizontally, even though it may not fit within the boundaries of the viewable area.

There are two ways to specify the word wrapping settings for multiline text field: one for authoring time control, and another for runtime control. Both ways result in the same ...

Get Flash 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.