How can the text in a Label control (or a similar control) be wrapped in Flex 4 beta? In Flex 3 I could use the Text control but this is no longer available in Flex 4.
问题:
回答1:
You can use maxDisplayedLines
and lineBreak
properties with spark Label
component:
<s:Label maxDisplayedLines="{-1}" lineBreak="toFit" text="...." />
It works with Flex 4.5.
回答2:
Try <s:SimpleText />
. From the excellent Migration Guide (p. 75):
The lightest-weight component of the text primitives. The SimpleText class supports the least number of text features. This class is similar to the Label class, except that it supports multiple lines. It does not support user ineractivity such as selection, editing, or scrolling.
Hope that helps!
回答3:
Spark Label can display multiple lines, which MX Label cannot:
In Spark Label, three character sequences are recognized as explicit line breaks: CR (
"\r"
), LF ("\n"
), and CR+LF ("\r\n"
).If you don't specify any kind of width for a Label, then the longest line, as determined by these explicit line breaks, determines the width of the Label.
If you do specify some kind of width, then the specified text is word-wrapped at the right edge of the component's bounds, because the default value of the lineBreak style is
"toFit"
. If the text extends below the bottom of the component, it is clipped.To disable this automatic wrapping, set the lineBreak style to
"explicit"
. Then lines are broken only where the text contains an explicit line break, and the ends of lines extending past the right edge is clipped.