1 Reply Latest reply: Aug 3, 2011 7:21 AM by JcFx.Eu RSS

    RichTextEditor.TextArea backgroundColor broken in Flex 4.*

    JcFx.Eu Community Member

      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

        • 1. Re: RichTextEditor.TextArea backgroundColor broken in Flex 4.*
          JcFx.Eu Community Member

          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