public function drag(e:MouseEvent)
{
lineDraw(mouseX, mouseY);
e.updateAfterEvent();
}
public function lineDraw(X:int, Y:int):void
{
currentX = X;
currentY = Y;
graphics.lineStyle(size, color)
graphics.moveTo(previousX, previousY)
graphics.lineTo(currentX, currentY)
previousX = currentX;
previousY = currentY;
}
Very simple code I made that allows me to draw lines with my mouse. Function drag is triggered on MOUSE_MOVE
after MOUSE_DOWN
.
My question is: how would I go about clearing the last line drawn? Basically, a ctrl+z/undo
function that can be repeat as many times as i want.
Would I have to rewrite my code completely and push every single line drawn into an array, and then work my way backwards through the array, removing lines as I click "undo"? Or is there another better, easier solution to this?
Thanks! :)