Have you ever wanted to have multi-line text in your label component in spark and thought the following should work?
[codesyntax lang="mxml"]
<s:Label text="I like text on the \n next line" />
[/codesyntax]
But all it produces is:
Yep me too.
After some playing however I stumbled accross the following solution:
[codesyntax lang="mxml"]
<s:Label text="I like text on the {'\n'} next line" />
[/codesyntax]
It then produces the expected result:
Im just guessing but I suspect its something to do with the black art of the flex life cycle. By adding the {'\n'} we are turning the property initialisation on the label component from a simple literal assignment into a delayed binding assignment and therefore gets parsed differently.
Just a guess, let me know if im way off.
thanks for that. this is a strange one, and it had me a little foxed this evening. anyway, cheers for the heads-up. I'll try it now and see if it fixed the problem Ive been having
ReplyDeleteGreat post! I used this on the s:FormItem label property. Any suggestions on how to vertically align the FormItem label with its content?
ReplyDeleteGlad you liked it mate :) Never used a FormItem so couldnt say im afraid
ReplyDelete