Search code examples
actionscript-3apache-flexairflash-builder

Flex 4 <s:Label Word wrap


I try to display a text with a Label component. In some case text is longer than label weight. So I hope to use something like word-wrap option to display text on 2 lines.

 <s:BorderContainer height="26" width="100%" borderStyle="inset" id="bcDos">
     <s:Label text="{phpImportant}" 
              textAlign="center"
              fontWeight="bold" 
              color="#FF0730" 
              fontSize="12"
              paddingBottom="1" 
              paddingTop="1"
              width="100%" 
              height="100%" 
              maxDisplayedLines="2"/>
 </s:BorderContainer>

With this code, only 1 line is displaying. If there is more text than the label can display, Label truncate the text for me with a truncation indicator such as "...". In my dream I'd like to have automatic word-wrap on 2 lines.

Thanks for helping.


Solution

  • You've indicated a height of 26px for your Label, which for its current font properties (fontSize, fontWeight, ...) can not show more than one line.

    So to show your text on two lines, you've to use an appropriate height value or simply keep that property empty so your label will be resized automatically :

    <s:Label text="{phpImportant}" textAlign="center"
        fontWeight="bold" color="#FF0730" fontSize="12"
        paddingBottom="1" paddingTop="1"
        width="100%" maxDisplayedLines="2"
    />
    

    Hope that can help.