Skip to main content
Known Participant
July 21, 2009
Question

How Adding an operation queue Undo Redo using addChild from TextFlow ?

  • July 21, 2009
  • 1 reply
  • 1205 views

Hi,

I wanna to add a operation in the queue of operations, when I run the following code.

EditManager(textFlow.interactionManager).beginCompositeOperation()

var para:ParagraphElement = new ParagraphElement();
var spanBullet:SpanElement = new SpanElement();
var span:SpanElement = new SpanElement();
                                   
spanBullet.text = "1."
span.text = "testing";
           
para.addChild(spanBullet);
para.addChild(span);

textFlow.addChild(para);

EditManager(textFlow.interactionManager).endCompositeOperation();

Thus does not work, I wonder if you can help me, thanks. Excuse my english, but i dont speek english,
This topic has been closed for replies.

1 reply

Adobe Employee
July 22, 2009

To create your own operation you should subclass FlowOperation.  Then write a doOperation undo and redo method.  When you actually want to execute the operation call EditManager.doOperation with an instance of your subclass.

In this case you don't need begin/endCompositeOperation.  Those methods are for combining multiple FlowOperations into a single operation.

Hope that helps,

Richard

Known Participant
July 22, 2009

Hi Richard,

Thanks for reply


But then I needed to run this code and it to be undone when I press Control + z, which not happen, because the method addChild not enter the queue of operations, thus firing an error.

It can not do a complex operation like this using only FlowOperation because I did not find methods to add DivElement, ParagraphElement, SpanElement with FlowOperation inside a TextFlow

I finded this class InsertTextOperation, and I tried to use it, but that does not allow me add a ParagraphElement or DivElement per exemple.

Just an observation, I think that addChild method does not fire FlowOperationEvent and therefore not enter the queue of operations.

Please help me.
Adobe Employee
July 22, 2009

The closet thing to adding a paragraph is SplitParagraphOperation.  Do that at the end of a Paragraph.

Model changes (addChild/removeChild etc.) are not automatically recorded for undo.  Each operation is responsible for recording initial state to undo (and later redo) the change.

By the way more recent docs are available here:

http://livedocs.adobe.com/flex/gumbo/langref/

Richard