<s:Label id="labelA"
backgroundColor="{labelA.isTruncated ? 0xFF0000 : 0xFFFFFF}" />
However, the isTruncated property isn't bindable, so you need to dig a little deeper. Inside the TextBase class, the setIsTruncated() method dispatches a isTruncatedChanged event when the truncation state changes. This event isn't in the meta data, so you need to assign an event handler manually:
<s:Label id="labelB"
creationComplete="labelB_creationCompleteHandler(event)"/>
The creation complete handler assigns a further handler when the isTruncatedChanged event is fired to set the background colour:
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function labelB_creationCompleteHandler(event:FlexEvent):void
{
labelB.addEventListener('isTruncatedChanged', isTruncatedChangeHandler)
}
private function isTruncatedChangeHandler(event : Event):void
{
labelB.setStyle('backgroundColor', labelB.isTruncated ? 0xFF0000 : 0xFFFFFF);
}
]]>
</fx:Script>
Add a comment