Here's a basic example implementation in case it helps anyone. Right now I'm only dispatching events for pushUndo() but it portrays the idea. I also haven't exposed how many items are in the undo list, but that should be easy. I likewise felt the UndoManager should dispatch events by default. Maybe the decision was made as an optimization thing, but I wouldn't think it would make much of a hit. package controller.textUndo { import flash.events.Event; import flash.events.EventDispatcher; import flash.events.IEventDispatcher; import flashx.undo.IOperation; import flashx.undo.UndoManager; [Event(name="undoPushed", type="svg.controller.textUndo.TextUndoManagerEvent")] public class EventfulUndoManager extends UndoManager implements IEventDispatcher { public function EventfulUndoManager() { super(); } override public function pushUndo(operation:IOperation):void { super.pushUndo(operation); dispatchEvent(new TextUndoManagerEvent(TextUndoManagerEvent.UNDO_PUSHED, operation)); } private var _dispatcher:EventDispatcher; protected function get dispatcher():EventDispatcher { if (!_dispatcher) { _dispatcher = new EventDispatcher(this); } return _dispatcher; } public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void { dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference); } public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void { dispatcher.removeEventListener(type, listener, useCapture); } public function dispatchEvent(event:Event):Boolean { return dispatcher.dispatchEvent(event); } public function hasEventListener(type:String):Boolean { return dispatcher.hasEventListener(type); } public function willTrigger(type:String):Boolean { return dispatcher.willTrigger(type); } } }
... View more