Tuesday, February 9, 2010

Flex mx:Label htmlText and Font color behaviors

I just discovered a few qwerks with the Flex Label’s htmlText property that I thought were worth passing along.

First off, Labels are limited to one line, so the default behavior of the <mx:htmlText> <![CDATA[ will not display:

<mx:Label>

      <mx:htmlText>

            <![CDATA[

                  <font color="Red">*</font> indicates required field.

                  ]]>

      </mx:htmlText>

</mx:Label>

Once I consolidated the the CDATA lines into one it displayed:

<mx:Label>

      <mx:htmlText>

            <![CDATA[ <font color="Red ">*</font> indicates required field.]]>

      </mx:htmlText>

</mx:Label>

…but the color still didn’t work.  Turns out you have to use Hex to specify font color:

<mx:Label>

      <mx:htmlText>

            <![CDATA[ <font color="#FF0000">*</font> indicates required field.]]>

      </mx:htmlText>

</mx:Label>

The Adobe LiveDocs explain all this in more detail.

No comments: