ActionScript 3 TextArea htmlText styling using <span> tag

saurb picture saurb · Oct 27, 2009 · Viewed 17k times · Source

According to this webpage, the htmlText property in TextArea can handle CSS text style if using span tag. I want to format multiple tags in my code. Something like:

var tags:TextArea = new TextArea(); 
tags.htmlText = "<span style='color: rgb(165, 150, -90); 
  font-size: 0.955882610016677em'>street</span>,
  <span style='color: rgb(168, 143, -59); font-size: 0.98076913067067em'>
  motor</span>";

It only gives me plain text. I was wondering if it is supported in the htmlText property and how do I get around this. Any ideas? Thanks!

Answer

Amarghosh picture Amarghosh · Oct 27, 2009

The htmlText supports only a limited set of tags and styles. Specifically, span supports only a class attribute which should be the name of a class specified in a StyleSheet object.

You can use the font tag in this particular case. But remember that color supports only hexadecimal #ffffff values and size supports only absolute pixel size and relative (+2, -1 etc) size values.

tags.htmlText = "<font color="#a89433" size="10">street</font>,
  <font color="#b37620" size="11">motor</font>";