Advanced undo/redo in an AIR app using AS3
As a short follow-up post to the basic undo/redo functionality from the other day, here's a really simple approach to adding more advanced kinds of undo/redo.
In the same place you added the 'addBasicUndoItem' method from the previous post, you could add this method:
public function addAdvancedUndoItem( o : Object ) : void {
	_redo = [];
	_undo.push( o );

Yup. Some simple steps:
  1. The class managing undo/redo admits that it has no clue about more complex undo/redo situations
  2. Hand the definition of complex undo/redo situations over to the relevant class.
  3. Give the relevant class a simple method to throw the undo/redo item on the managing stack.
In other words, if another class 'ClassA' has a method named 'complexAction', then that class would probably be best suited to defining the undo/redo functionality associated with the 'complexAction'.
public class ClassA{
    public function complexAction() : void {
            undo:function():Object{ /* Some complex functionality */ return this; },
            redo:function():Object{ /* Some complex functionality */ return this; }

Again, not too bad.