问题
i've been unsuccessfully attempting to create my own undo/redo classes that work well with any type of possible undo and redo commands.
for example, my simple class works perfectly with undoing/redoing x and y positions of display objects or undoing/redoing values of sliders, etc., but things get dicey when i try to tailor my classes to also work with things like adding and removing items to a list.
is there any well known and well documented solution for general undoing and redoing for actionscript (without Flex)?
回答1:
There are specific design patters for this kind of stuff in AS3
Please check the following links: http://lucamezzalira.com/2010/01/12/memento-pattern-in-actionscript-3-undoredo/
you can also check Command pattern, which is the de-facto standard ,irrespective of the programming language, it would give you the basics.
Incase you face any issues, please feel free to comment.
来源:https://stackoverflow.com/questions/4713172/actionscript-general-undo-redo-api