8.11. Condensing Whitespace
Problem
You want to condense whitespace in an HTML text field display.
Solution
Set the object’s condenseWhite
property to true.
Discussion
When you use HTML in a text field, the optional
condenseWhite setting condenses whitespace, as is
done in most HTML browsers. For example, the following text would be
rendered in a web browser with only a single space between
“hello” and
“friend” in spite of the fact that
the original source has multiple spaces between the two words:
hello friend
In ActionScript text fields, however, all of the spaces are displayed
unless you set the condenseWhite property to
true.
myTextField.html = true; myTextField.condenseWhite = true; myTextField.htmlText = "hello friend"; // Displays: "hello friend"
The condenseWhite property works only when the
html property is true.
See Also
Recipe 8.10 and the
XML
.ignoreWhite
property
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access