November 19th, 2007 by Kyle
Posted in: Flex, actionscript, mxml
I had a customer who was having problems with linebreaks in her Flex code.
I had used linebreaks before with no problem until I realized that she was setting text with linebreaks in mxml and not setting properties dynamically as I had done in all instances in teh past when dealing with linebreaks.
I search the Adobe public bugbase and found this bug:
http://bugs.adobe.com/jira/browse/SDK-12649
I thought I’d write a simple app to demonstrate the problem and workarounds.
Here is the source for the app:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Label id="ta1" height="75" width="250" text="This does not \nwrap"/>
<mx:Button label="click to set via actionscript" click="ta2.text=’Setting via actionscript and\nthis does wrap’"/>
<mx:Label id="ta2" height="75" width="250"/>
<mx:Label id="ta3" height="75" width="250" text="Alternatively with this workaround,{’\n‘}this wraps too"/>
</mx:Application>
Browse the source of this example.
Download a zipfile containing the source to this sample.





Recent Comments