Skip to main content
Participant
June 16, 2010
Question

Updating a textFlow

  • June 16, 2010
  • 1 reply
  • 830 views

Hi everyone,

How can i update a textFlow?

i create a TextFlow like this :

var ca:TextLayoutFormat = new TextLayoutFormat();

ca.fontLookup = FontLookup.EMBEDDED_CFF;

var container:Sprite = new Sprite();

addChild(container);

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

textFlow.hostFormat = ca;

textFlow.flowComposer.addController(new ContainerController(container, 400, 200));

textFlow.flowComposer.updateAllControllers();

_markup is a XML and i want to replace _markup by another XML without removing the textFlow. How can i do this?

Thanks.

This topic has been closed for replies.

1 reply

Adobe Employee
June 17, 2010

Easiest way that I've found is to use the TextConverter to create a second TextFlow with the new markup. Then

replace the children in the original TextFlow with the children from the new TextFlow, and copy the properties over.

- robin

Participant
June 17, 2010

Thanks for your answer.

Your method is more a hack than a solution. I mean that's cool, it does visually what i want but i can't believe there is not a real update method.

Anyway thank you again, i'll use your method until i find a real solution.

A_Shiyaz
Known Participant
August 17, 2010

You can use this:

var selState = new SelectionState(textFlow, 0, textFlow.interactionManager.absoluteEnd);
EditManager(textFlow.interactionManager).deleteText(selState);
EditManager(textFlow.interactionManager).overwriteText("abc", selState);

If you just want to append content, just use:

EditManager(textFlow.interactionManager).overwriteText("abc");

~ Shiyaz

[Edit]:

For some reason, the absoluteEnd gives -1 at times. However, we need the length of the text. Hence, use this:

var str = TextConverter.export(textFlow, TextConverter.PLAIN_TEXT_FORMAT, ConversionType.STRING_TYPE) as String;
var selState = new SelectionState(textFlow, 0, str.length);
EditManager(textFlow.interactionManager).deleteText(selState);
EditManager(textFlow.interactionManager).overwriteText("abc", selState);

~ Shiyaz

Message was edited by: A.Shiyaz