PDA

View Full Version : Paint "Undo" function not working



RyuMaster666
May 17th, 2009, 09:55 AM
Hi! I'm trying to do bitmap undo function.
Like, I perform some operations with bitmapdata (puttin' pixel there, filling with color);
I have those two functions. bmdCavas it tied to actual Bitmap with image, which is placed on screen.
last_step is BitmapData as well.

function on_undo_btn (ev:MouseEvent)
{
bmdCanvas = last_step.clone();
}
function undo_save()
{
last_step = bmdCanvas.clone();
}

But this code is not working. Should I redraw image after changing itx bitmapdata or something?
or maybe I have to do undo function with bitmap itself?

dandylion13
May 17th, 2009, 11:26 AM
It might be overkill for your project, but if you want a really robust undo system in your application, consider implementing the "Command" design pattern: http://en.wikipedia.org/wiki/Command_pattern. It will be a bit more work, but probably worth it. This book describes how to implement it in AS3.0: http://www.amazon.ca/ActionScript-3-0-Design-Patterns-Programming/dp/0596528469

RyuMaster666
May 17th, 2009, 12:48 PM
Thank you! That is useful information. But unfortunate, I have to finish project today and do not have time to implement complex function. That is why all I want is to get working this simple 1-level undo.