When you type text manually in a Rich Text Editor and you change the background
color of the Rich Text Editors textArea, most of the markup will disappear. If
you add text by pressing by code (by pressing the a button for example), the
markup will remain when you change the background color.

By having a button that adds text and removes that text again, before it
changes the background color, you get a work-around. People then can manually
type text and change the background color without losing their markup.

But this still is a very ugly fix. And I wonder what actually is the problem?
And if there is a better solution.

Kind regards,
Zouhair Himdi

PS. If you compile the attached code, you will see exactly what I mean.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns="*">
<mx:RichTextEditor
id="rte"
htmlText="&lt;TEXTFORMAT LEADING=&quot;2&quot;>&lt;LI>&lt;FONT
FACE=&quot;Helvetica&quot; SIZE=&quot;14&quot; COLOR=&quot;#0B333C&quot;
LETTERSPACING=&quot;0&quot; KERNING=&quot;0&quot;>T&lt;FONT
FACE=&quot;Verdana&quot; SIZE=&quot;10&quot;>he &lt;I>quick&lt;/I> &lt;FONT
COLOR=&quot;#663300&quot;>brown&lt;/FONT> fox &lt;A
HREF=&quot;[url]http://google.com/&quot;[/url] TARGET=&quot;_blank&quot;>jumps&lt;/A>
&lt;U>over&lt;/U> the &lt;B>lazy&lt;/B>
dog.&lt;/FONT>&lt;/FONT>&lt;/LI>&lt;/TEXTFORMAT>"
/>
<mx:Button
id="b1"
x="{rte.x}"
y="{rte.y+rte.height+20}"
label="Add some text"
click="rte.htmlText += '&lt;TEXTFORMAT LEADING=&quot;2&quot;>&lt;P
ALIGN=&quot;LEFT&quot;>&lt;FONT FACE=&quot;Verdana&quot; SIZE=&quot;10&quot;
COLOR=&quot;#0B333C&quot; LETTERSPACING=&quot;0&quot;
KERNING=&quot;0&quot;>ok&lt;/FONT>&lt;/P>&lt;/TEXTFORMAT>';"
/>
<int id="i" />
<mx:Button
id="b2"
x="{b1.x}"
y="{b1.y+b1.height+20}"
label="Change background color"
click="rte.textArea.setStyle('backgroundColor',i=i +(191*256+191*256*256))"
/>
<mx:Button
id="b3"
x="{b2.x}"
y="{b2.y+b2.height+20}"
label="Add some text. Remove it. And then change the color"
click="rte.htmlText += 'ok'; rte.htmlText =
rte.htmlText.substr(0,rte.htmlText.length-2);
rte.textArea.setStyle('backgroundColor',i=i+(191*2 56+191*256*256))"
/>
<mx:TextArea
id="ta1"
text="{rte.htmlText}"
x="{rte.x+rte.width+20}"
y="{rte.y}"
width="{rte.width}"
height="{rte.height}"
/>
<mx:TextArea
id="ta2"
x="{ta1.x}"
y="{ta1.y+ta1.height+20}"
width="{ta1.width}"
height="{rte.height}"
backgroundAlpha="0"
htmlText="When you type text manually in a Rich Text Editor and you change
the background color of the Rich Text Editors textArea, most of the markup will
disappear. If you add text by pressing by pressing the add some text button,
the markup will remain when you change the background color.&lt;br />&lt;br
/>This is weird, because the add text button simply adds the exact same HTML
text that would be added if one would type 'ok' manually in the Rich Text
Editor.&lt;br />&lt;br />By having a button that adds text and removes that
text again, before it changes the background color, you get a work-around.
People then can manually type text and change the background color without
losing their markup."
/>
</mx:Application>