Skip to main content
Known Participant
November 25, 2009
Question

TextArea#insertXML, what's the simplest way so it works like TextArea#insertText?

  • November 25, 2009
  • 1 reply
  • 430 views

I would like to be able to insert an xml block of TLF-formatted xml, to be converted into flow elements, but without having to do it all manually.  So I'm looking for something that works like the TextArea's "insertText" method, which takes a string and inserts all the FlowElements into the anchor's position, doing all the work for you.

Is this possible?  Could this be included in the framework?  If not, could you please point me in the right direction

Something like:

var xml:XML =

<div styleName="myDiv">

     <span styleName="myStyle">

          Im Text

     </span>

</div>

textArea.insertXML(xml);

Thanks,

Lance

This topic has been closed for replies.

1 reply

viatroposAuthor
Known Participant
November 28, 2009

It's far too complex to do it manually with var element:FlowElement, etc.  It'd be nice if there was an InsertXMLOperation class that inserted XML snippets into the TextFlow, converting them to the appropriate objects.

Is Adobe planning on implementing something like this?  You guys could whip it out in an hour I bet, it'd take me forever to figure out how to do it properly.  Could you do this?

Adobe Employee
November 30, 2009

I'm not too conversant with TextArea, but you could look at the Flex spark code for

RichText or RichEditableText and see what it's doing with TextConverter. Basically, you can use the TextConverter class to get a TextFlow, and then it is a matter of how you can set the TextFlow as the content value.

This will get you a TextFlow given some markup:

     var textFlow:TextFlow = TextConverter.importToFlow(markupString, TextConverter.TEXT_LAYOUT_FORMAT);

Hope this helps,

- robin