• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

RichTextEditor.TextArea backgroundColor broken in Flex 4.*

Explorer ,
Aug 03, 2011 Aug 03, 2011

Copy link to clipboard

Copied

I have a simple application which uses a RichTextEditor with a colored background, like so:

richTextEditor = addChild(new RichTextEditor()) as RichTextEditor;

richTextEditor.textArea.setStyle("backgroundColor", 0xAAAAAA);

richTextEditor.title = "Edit Text:";

richTextEditor.htmlText = formattedText;

This works fine when I compile against Flex 3.5.0, but in Flex 4.0 and 4.5, the background color remains white. I've tried setting it before the text, after the text, before and after it is added to the stage - even every single frame with an EnterFrame handler. Nothing - it just stays white.

Has anyone else encountered this and does anyone have a workaround? I don't really want to switch to a Spark component if I can help it, and I can't downgrade the whole application to 3.5.

Any answers much appreciated - as always.

JcFx

TOPICS
ActionScript

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 03, 2011 Aug 03, 2011

Copy link to clipboard

Copied

LATEST

I have an ugly hack fix for this, but I'm still not sure why it's happening. Here's the workaround:

richTextEditor = addChild(new RichTextEditor()) as RichTextEditor;

richTextEditor.setStyle("backgroundColor", 0xAAAAAA);  /* NOT THE TEXT AREA, THE RTE ITSELF */
richTextEditor.title = "Edit Text:";

richTextEditor.htmlText = formattedText;

callLater(hideBackground);

     protected function hideBackground():void
     {
            //Console.Debug("TextFieldEditor hideBackground");
            if (richTextEditor)
            {
                if (richTextEditor.textArea)
                {
                    for (var i:int = 0; i < richTextEditor.textArea.numChildren; i++)
                    {
                        var object:DisplayObject = richTextEditor.textArea.getChildAt(i);
                        var className:String =  getQualifiedClassName(object);
                         if(className == "mx.skins.spark::BorderSkin") richTextEditor.textArea.getChildAt(i).visible = false;
                    }
                }
            }
        }

- You need to callLater(hideBackground); every time the editor's text or htmlText is updated.

Hope this helps someone in future. It has to be good enough for me at the moment but I'd still like to know why the setStyle call is failing.

JcFx

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines