f = function(s){ //reference to the executing function object var self = arguments.callee //if the array does not exist create it if(self.a ==undefined) self.a = [] //getter if(arguments.length <1){ //pop and item off the array var r = self.a.pop() trace("Undo : " + r) //return the value return r //setter }else{ trace("Do : " + s) //push an item onto the array self.a.push(s) } } addProperty('history',f,f) delete f history = "Wake Up" history = "Shower" history = "Brush Teeth" history = "Make Bed" history = "Make Coffee" history = "Cook Bacon" // Forgot to get dressed undo 3 steps history history history history = "Get Dressed" history = "Make Bed" history = "Make Coffee" history = "Cook Bacon" // I shouldn't have gotten up today history history history history history history history /* trace Do : Wake Up Do : Shower Do : Brush Teeth Do : Make Bed Do : Make Coffee Do : Cook Bacon Undo : Cook Bacon Undo : Make Coffee Undo : Make Bed Do : Get Dressed Do : Make Bed Do : Make Coffee Do : Cook Bacon Undo : Cook Bacon Undo : Make Coffee Undo : Make Bed Undo : Get Dressed Undo : Brush Teeth Undo : Shower Undo : Wake Up */