post header image for Multi-Line Flex Label [MXML]

Multi-Line Flex Label [MXML]

Just stumbled across this one while writing some mxml for a personal project and thought I would share.

Have you ever wanted to have multi-line text in your label component in spark and thought the following should work?


<s:Label text="I like text on the n next line" />

But all it produces is:

Yep me too.

After some playing however I stumbled accross the following solution:


<s:Label text="I like text on the {'n'} next line" />

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.

GET NEW POSTS BY EMAIL

About one post a month on AI, coding, games and side projects. No spam, unsubscribe any time.

COMMENT