I want to programmatically insert formatted text at the current cursor position in a Flex 4 (Spark) RichEditableText control. I could just modify the .text property.... But that doesn't allow me to insert formatted text. So I believe I need to interact with either .textFlow or .textFlow.interactionManager somehow? However, TLF is quite complex and I can't find a simple way to do what I want.
A:
This seems to do it. It's a lot of work though. Not sure how I feel about all the added complexity of the new text layout framework in Flash.
var txt:RichEditableText;
var html:String = "<b>some <i>rich</i> text</b>";
var mgr:EditManager = txt.textFlow.interactionManager as EditManager;
var flow:TextFlow = TextConverter.importToFlow(html, TextConverter.TEXT_FIELD_HTML_FORMAT);
mgr.pasteTextScrap(new TextScrap(flow));
davr
2010-10-08 19:47:06