A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Adding "undo/redo" functionality

  1. #1
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549

    resolved [RESOLVED] Adding "undo/redo" functionality

    Okay, so I have created a pretty nice custom animator for ease of animating character models for a game I've been working on. You can check it out (so far) here.
    HOTKEYS:
    **Use "-" and "=" to add backward and forward onion-skin layers, respectively.
    **Use "SHIFT -" and "SHIFT =" to remove the onion-skin layers.
    **Use "." and "," to step forward and backward between frames, just like in Flash.


    However, I am trying to add undo/redo actions, and, although I have figured something out that will work, I'm not exactly sure if there is a better way to go about doing this.


    Obviously just saying "undo/redo functionality" is pretty vague and generalized, so here are some specifics:

    I have only a few specific types of actions that I would ever have to undo/redo:
    -changing the rotation of a segment
    -moving the model's position (x,y)
    -inserting a new frame (new frame will be the next frame forward from the current frame)
    -removing the current frame
    -swapping the current frame with the previous frame
    -swapping the current frame with the next frame

    What would be the most efficient way to work with this? Seeing as there are only a few possibilities, I would figure that it would be easiest to program how to deal with undoing/redoing each specific type of action. Am I right to think that? Or is there a better way to do it?
    Z¡µµ¥ D££

    Soup In A Box

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Very nice! instead of replacing the old value with the new one, you'll need an extra step in between. say i change ftoes from 0 to 15.66, you'll have ftoes_old = 0 (default: all vars start with an _old paired var) and ftoes_new = 15.66, ftoes = ftoes_new; upon undo : ftoes = ftoes_old, upon redo ftoes=ftoes_new.

    gparis

  3. #3
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    Great, thanks! That worked perfectly! I now have a working undo/redo!
    Z¡µµ¥ D££

    Soup In A Box

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center