If you're having trouble getting word wrapping to work correctly in your mx:Text components when using
The Flex SDK mx:Text component word wrap bug fix article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.
minWidth and maxWidth, and setting width to a percentage (e.g., minWidth="0" maxWidth="300" width="100%"), it's not you, it's the Flex SDK (see bug 12826, reported by Tom Bray).
The fix, as provided by Mike Schiff, has been implemented in the SDK but until it is released you can extend mx:Text and implement it in your own projects:
<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); textField.wordWrap = textField.wordWrap || (Math.floor(measuredWidth) != Math.floor(width)); } ]]> </mx:Script> </mx:Text>
The Flex SDK mx:Text component word wrap bug fix article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.
[...] > Aral Balkan – Flex SDK mx:Text component word wrap bug fix [...]
Actually you do not have to extend the Flex component. Just do this in your code: textField.setStyle(“textField.wordWrap “,”textField.wordWrap”);
Cheers
/Niels
Niels Bjerg, you rule
The topic is quite trendy in the net right now. What do you pay attention to when choosing what to write about?
Thanks, but didn’t work for me.
I had to change it like this;
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
textField.height = unscaledHeight;
}