绘图应用程序如何在actionscript 3中创建撤消功能?

时间:2013-02-21 18:40:11

标签: actionscript-3 function undo

任何人都可以告诉我如何进行撤消功能?所以这是我当前的动作脚本。我不知道如何做到这一点,我在一些网站上看到一些例子,动作脚本是长期以来的立场。请说明一种简单的方法,我可以使这项工作。

抱歉语法不好......

import flash.display.MovieClip;
import flash.events.MouseEvent;

var pen_mc:MovieClip;
var drawing:Boolean = false;
var penSize:uint = 1;
var penColor:Number = 0x000000;



function init():void{

pen_mc = new MovieClip();
stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
stage.addEventListener(MouseEvent.MOUSE_MOVE, isDrawing);
stage.addEventListener(MouseEvent.MOUSE_UP, finishedDrawing);
addChild(pen_mc);

}

init();

function startDrawing(e:MouseEvent):void{

trace("Pen Has started drawing");

drawing = true;
pen_mc.graphics.lineStyle(penSize, penColor);
pen_mc.graphics.moveTo(mouseX, mouseY);


}

function isDrawing(e:MouseEvent):void{
if(drawing){

    pen_mc.graphics.lineTo(mouseX, mouseY);
}

}


function finishedDrawing(e:MouseEvent):void{

     trace("finished drawing");
     drawing = false;

}

1 个答案:

答案 0 :(得分:1)

您希望存储用户在历史数组中绘制的每一行。当用户想要撤消时,您可以逐步向后遍历数组并逐个删除每一行。