Integrate mx RichTextEditor with spark RichText

2010 September 28
by admin

One of the greatest things about Flex 4 is the new TLF text layout controls. It is amazing how much more control they give you over the flow and layout of the text. It’s also great to be able to add animation or rotation to the text components without having to perform some sort of Bitmap hack like you had to in Flex 3. However, there is currently no flex 4 (spark) RichTextEditor to integrate with these components.

I looked online in hopes to find an out of the box solution that I could use similar to the mx RichTextEditor. Although I found a lot of great examples, none of them worked as seamlessly as the mx RichTextEditor that was already provided by adobe. I didn’t have the time to mess with someone else’s RichTextEditor or even write my own. So I decided to try to integrate the mx RichTextEditor with the new TLF Classes. As it turns out there is a TextConverter class that can be used to do exactly what I wanted.

Here is an example for how to convert the htmlText from a RichTextEditor to a textFlow element:

1
2
3
4
var txt:RichText;
var rte:RichTextEditor;

txt.textFlow = TextConverter.importToFlow(rte.htmlText, TextConverter.TEXT_FIELD_HTML_FORMAT);

Comments are closed.