I've hit a bit of a wall on this particular issue. I've got a multi-user whiteboard that contains both normal text fields as well as TLF text fields. I'm working in oure AS3 - no Spark components are used.
What I need to achieve is updating the value (the contents so to speak) from one user's screen to another. Example: user A creates a new TLF text object on screen and types something. I'm creating a Textflow object and I add it to a container. Since all interactions on the whiteboard are synced I also send a command over the wire that forces the same object to be created on User B's screen. So far so good.
I now listen for changes to the textflow object:
private function onTextChange(event:UpdateCompleteEvent):void
var newString:Object = TextConverter.export( TextFlow(event.textFlow), TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.STRING_TYPE );
I then send the newString Object over the wire from user A to user B. Effectivelt all I want to sync is the alue of the text inside the textflow object which may contain multiple paragraphs. Right now I send something liek the following over the wire:
<TextFlow direction="rtl" fontSize="12" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" paragraphSpaceAfter="2" paragraphSpaceBefore="2" whiteSpaceCollapse="preserve" version="2.0.0" xmlns="http://ns.adobe.com/textLayout/2008"><p><span>Start</span></p></TextFlow>
On user B's screen I then try to import this string:
textFlow = TextConverter.importToFlow( msg, TextConverter.TEXT_LAYOUT_FORMAT );
Unfortunately TextConverter.importToFlow returns a new TextFlow instance and I cannot figure out how to replace just the contents of the existing TextFlow instance that's already on user B's screen.
Am I missing a particular API? Is there a way to say: "I've got a textflow instance on stage, now take this string and import it, starting with the first paragraph - but do not replace my xisting TextFlow instance."
I hope I am explaing myself well enough. In a nutshell: how can I import the contents of a TextFlow object instance into another TextFlow object instance without replacing that second instance (which is what TextConverter.importToFlow seems to do)?
Replaces child elements in the group with the specified new elements.
The function above may work for you. You can firstly TextConverter.export to get a new textflow. Then replace the children of the original textflow with those of the new exported textflow.