Skip to main content
August 25, 2009
Answered

SpanElement backgroundColor not working as expected

  • August 25, 2009
  • 1 reply
  • 983 views

I am adding a simple RichText element with a SpanElement as the content. I am setting the backgrounColor of the span, but rather than highlighting the entire text, it is only highlighting the top few pixels of the first line of text.

Is this a bug or am I doing something wrong?

<?xml version="1.0" encoding="utf-8"?>

<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:mx="library://ns.adobe.com/flex/halo"

width="100%" height="150"

horizontalScrollPolicy="off" verticalScrollPolicy="off"

xmlns:s="library://ns.adobe.com/flex/spark">

<fx:Script>

<![CDATA[

[Bindable]

public var imageUrl:String;

[Bindable]

public var caption:String;

]]>

</fx:Script>

<mx:Image source="{imageUrl}" width="210" height="150" x="{(width - 210) / 2}" />

<s:Group>

<s:RichText width="135" height="100%">

<s:content>

<s:span fontSize="16" fontFamily="times, serif" color="#000000" backgroundColor="#ff0000" text="{caption}"/>

</s:content>

</s:RichText>

</s:Group>

</mx:Canvas>

This topic has been closed for replies.
Correct answer

OK - I can reproduce the problem with that version of the Flex SDK. The good news is that I can not reproduce it in today's build (4.0.0.10096). So it looks like someone else noticed the problem and fixed it at some point.

1 reply

September 10, 2009

What version of the Flex 4 SDK are you using?  I could not reproduce this in my (admittedly old) version.

September 10, 2009

It says version 4.0.0 build 7219.