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:label>
</mx:label></mx:button></mx:label></mx:application>

Browse the source of this example.
Download a zipfile containing the source to this sample.

This movie requires Flash Player 9




2 Comments »