我建议研究命令设计模式。
本质上,您的数组将不包含图像,而是代表对图像进行的操作的标记。每个令牌都有足够的信息来撤消(和重做?)其操作。
var c:Command = new RotateCommand(90, CLOCKWISE);
c.doWork();
history.push(c);
// Undo
var c:Command = history.pop();
c.undoWork();
然后在命令中,大致:
public function doWork():void {
var newTransform:Matrix = calculateTransform(angle, direction); // 90, CLOCKWISE
image.transform.matrix.concat(newTransform);
}
public function undoWork():void {
var newTransform:Matrix = calculateTransform(-angle, direction); // reverse operation
image.transform.matrix.concat(newTransform);