PDA

View Full Version : Styling text in mx:Text controls


Jasconius
05-20-2008, 07:46 PM
This is my first foray into Flex and one of the burning questions I have been having this past week is what sort of options do I have for controlling the styling of text within these Text controls?

Obviously I can apply a singular style to the control (which I am doing) but in my case there are many times where I need to bold or italicize some text in this control and it seems... impossible? When I attempt to italicize a word it simply italicizes the entire box and it ignores simple HTML tags when used in conjunction with the htmlText property.

I see this TextRange thing and it looks promising but I can't seem to get it to work correctly.

I also read that you can apply some sort of stylesheet or something directly to a TextArea but why can't you do this to a Text control?

Tips, articles, what have you, all welcome.

Thanks

bfrancis
05-22-2008, 07:43 PM
Hi

Just use the htmltext property of the Text tag:

<mx:Text>
<mx:htmlText>
<![CDATA[hello I am very <b>bold</b> and slightly <i>bent</>]]>
</mx:htmlText>
</mx:Text>

Jasconius
05-22-2008, 07:53 PM
That doesn't seem to work if you also need to apply a CSS class to the entry.

kahuja
05-23-2008, 01:52 PM
to change styles you should be using setStyle function on the control.