popUndo broken queue undo
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextFilter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.edit.IUndoManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.InlineGraphicElement;
import flashx.textLayout.elements.InlineGraphicElementStatus;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.events.StatusChangeEvent;
import flashx.textLayout.formats.Float;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.operations.InsertInlineGraphicOperation;
import flashx.undo.UndoManager;
public class InlineGraphicUndoRedo extends Sprite
{
private static const markup:String = '<?xml version="1.0" encoding="utf-8"?><TextFlow fontSize="14" paddingBottom="inherit" lineBreak="inherit" paddingTop="4" textIndent="15" verticalAlign="inherit" paddingRight="inherit" paddingLeft="4" whiteSpaceCollapse="preserve" xmlns="http://ns.adobe.com/textLayout/2008"><p marginBottom="15">This is some textttt.</p></TextFlow>';
public function InlineGraphicUndoRedo()
{
super();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var s:Sprite;
s = new Sprite()
addChild(s);
s.x = 10;
s.y = 200;
var textFlow:TextFlow = fillComposer(markup,s);
var em:IEditManager = textFlow.interactionManager as IEditManager;
var selState:SelectionState = new SelectionState(textFlow,1,1);
em.doOperation(new InsertInlineGraphicOperation(selState,'http://tarrascao.files.wordpress.com/2008/12/universo_digital.jpg',214,140,Float.NONE));
var img:InlineGraphicElement = textFlow.findLeaf(1) as InlineGraphicElement;
var cf:TextLayoutFormat = new TextLayoutFormat();
cf.lineHeight = 100;
var um = EditManager(textFlow.interactionManager).undoManager;
trace(um.peekUndo())
EditManager(textFlow.interactionManager).applyLeafFormat(cf,
new SelectionState(textFlow, img.getAbsoluteStart(), img.getAbsoluteStart()+1));
textFlow.flowComposer.updateAllControllers();
trace(um.peekUndo());
um.popUndo(); // whether comment this line, works, but is not what I need
trace(um.peekUndo())
textFlow.flowComposer.updateAllControllers();
}
private function fillComposer(markup:String,s:Sprite):TextFlow
{
var textFlow:TextFlow = TextFilter.importToFlow(markup, TextFilter.TEXT_LAYOUT_FORMAT);
var controller:ContainerController = new ContainerController(s,400,400);
textFlow.flowComposer.addController(controller);
textFlow.flowComposer.updateAllControllers();
textFlow.interactionManager = new EditManager(new UndoManager());
textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGED,graphicLoaded);
return textFlow;
}
static private function graphicLoaded(evt:StatusChangeEvent):void
{
if (evt.status == InlineGraphicElementStatus.SIZE_PENDING || evt.status == InlineGraphicElementStatus.READY)
evt.element.getTextFlow().flowComposer.updateAllControllers();
}
}
}
