My favorites | Sign in
Project Logo
                
Code license: MIT License
Labels: Flash, Flex, undo, redo, TextField, ActionScript3
Blogs:
Feeds:
People details
Project owners:
  jacwright

Undo and redo capabilities should have been built into Flash's TextField component. They exist in any modern browser's text inputs and it is very important for forms and other textual inputs to support undo and redo.

UndoTextFields can be added to the root of your movie or Flex application to provide undo/redo to all TextField components. Or you can add it to a given Sprite or MovieClip (or Canvas or VBox etc.) to enable only the text components inside of it to have undo/redo.

This will add two context menu items called "Undo Text" and "Redo Text". Flash doesn't allow an item simply called Undo or Redo to be added unfortunately. It also enables the keyboard shortcut Ctrl+Z for undo and Ctrl+Shift+Z and Ctrl+Y for redo. This has been tested on Firefox 3 on Mac, but not all browsers may let the keyboard shortcuts through to Flash. We may provide javascript support for this in the future.

UndoTextFields is dependent on the CommandHistory class and command pattern interfaces contained in the Flight Framework.

To use, create (and hold onto) an instance of UndoTextFields and set its target property to the DisplayObjectContainer you'd like. All TextFields which exist under that container will have undo enabled. Below is an example of what you might place on the root timeline in ActionScript:

import gearsandcogs.text.UndoTextFields;
this.undoTextFields = new UndoTextFields();
this.undoTextFields.target = this;

And the following is how you would use it in your Flex application:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:text="gearsandcogs.text.*">
    <text:UndoTextFields target="{this}" />
    ...
</mx:Application>








Hosted by Google Code