tags:

views:

4059

answers:

4

Can anyone tell me if it's possible to have a the text in a single label control displayed in more than one style.

e.g. I have a label

I want the the text to appear with the style "english" (which it does), but I want the "th" of the text to be different (bold, different colour, whatever).

So, the question in a nutshell is: Is there a flex equivalent of the following HTML?

<p class="english">bro<span class="highlight">th</span>er</p>

If not, can anyone think of a good workaround, short of having to separate the text into multiple label controls (thus making alignment a bit of a nightmare)?

Thanks to anyone who can help!

Dan

+1  A: 

yes, try the following

var la : Label;
la.htmlText = '<TEXTFORMAT LEADING="3"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="1">what ever texst you wish</FONT><FONT FACE="Verdana"SIZE="18" COLOR="#848484" LETTERSPACING="0" KERNING="1">more text here</FONT></P></TEXTFORMAT>';
kenneth
+1  A: 

Yes, it's possible. You probably want to take a look at this part of the livedocs.

There are a few ways to do what you want and that page has a fairly comprehensive list of them.

inferis
A: 

Thanks guys, you've answered what my Flex Bible and various Googles couldn't! Works just fine now ... thanks for your time :)

Dan
A: 

Thank you for this! I was going crazy. The last gotcha was the fact that the Label does NOT respect the
tag. That gem was buried in the LiveDocs.

Pete