-1

谁能告诉我如何使撤消功能?所以这是我当前的动作脚本。我不知道该怎么做,我在一些网站上看到了一些例子,动作脚本很长,无法理解。请展示一个简单的方法,我可以使这项工作。

对不起语法不好...

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;

}
4

1 回答 1

1

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

于 2013-02-21T19:40:18.000 回答