design patterns
Memento Pattern – Recording State
Here’s a little preview for the video I’m going to make tomorrow about the Memento Pattern.
To play with the .swf follows these steps:
1. Click the .swf to give it keyboard focus
2. Press the SPACE BAR to start your recording
3. Move the MOUSE around to change the red circle’s position
4. Press the SPACE BAR again to stop the recording
5. Press the LEFT and RIGHT keys to rewind and fast forward through actions you took
Neat trick, huh? ![]()

source
Command Pattern – Queuing Commands
This is a slight variation of the previous example, with a much different result. If you look at the source you’ll see that only the click handlers of the buttons have changed.
Now, whenever you click a green, red, or blue button each action will queue up waiting for you to click the black button. Once you click the black button, every action queued up (meaning each circle waiting to be created) will execute all at the same time.
Command Pattern – Undo and Command Stack
As requested, here’s a demo of the command pattern in action. This example shows how to use the Command Pattern to undo an action. Please watch the video in the previous post before browsing through this source.
Try to focus on how the commands are all added into the command stack, then you’ll see how the stack can be used for undoing, redoing, logging actions, queuing actions, and all sorts of other useful stuff
Click on the green, red, and blue boxes to create new circles. Click on the black box to undo.

source
ActionScript 3 – Command Pattern and Interfaces
Click to view the video in a pop-up. Right-click and “save as” to download the video to your hard drive.
Watch Video Tutorial on Command Pattern and Interfaces
Please consider donating $1 if you learned something valuable from this video. The money will go directly towards covering the costs of hosting the videos. I sincerely thank the few of you who have donated so far.
Search
Recommended Books
Speaking at FITC Toronto
Recent Posts
- FDT Theme Designer
- haXe Tutorial
- AS3 Signals Tutorial
- Preferred Video Tutorial Resolution?
- TweenMax – Tweening a timeline (Advanced Tweening)
- Robotlegs + Flight + Union Platform
- Back in the saddle
- Eclipse Theme Designer Preview
- RobotLegs Hello World Video Tutorial
- 10 Things Every Senior Flash Developer Should Know
- Efflex – 3D Effects for Flex
- MorphController – Mighty Morphing Papervision3D
- End dump
- Test if a plane is within the view of the camera (aka testing if culled)
- Materials Reference
Recent Comments
- BAM5 on haXe Tutorial
- AlexG on Finding 2D Coordinates of a DisplayObject3D
- Josh on ActionScript 3 – Model View Controller (MVC)
- martin everett on requests
- martin everett on requests
- lillacska on Dragging Spheres
- Guy Ritchie on MXML without the Flex framework
- Pedro on ActionScript 3 – Namespaces
- daveevolve on AS3DMod Perlin Noise
- sebomoto on haXe Tutorial
Categories
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jan | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 | ||||
Archives
Preferred Video Tutorial Resolution
- 1024x768 (53%, 85 Votes)
- 1280x1024 (15%, 24 Votes)
- 1920x1080 (15%, 24 Votes)
- 800x600 (13%, 20 Votes)
- 480x320 (4%, 6 Votes)
- 640x480 (0%, 2 Votes)
Total Voters: 160

