 			}
 			trace('undo ['+h+']','redo ['+f+']');
 		}
+		
+		/**
+		 * This version number is used to detect old history formats generated by serialize().
+		 * This value should be incremented each time modifications to this class would result in a different serialization format.
+		 */		
+		private static const _serializationVersion:int = 0;
+		
+		/**
+		 * This will write the session state log to a ByteArray.
+		 * @param output The output ByteArray.
+		 */
+		public function serialize(output:ByteArray):void
+		{
+			synchronizeNow();
+			
+			output.writeInt(_serializationVersion);
+			
+			output.writeObject(_prevState);
+			output.writeObject(_undoHistory);
+			output.writeObject(_redoHistory);
+			output.writeInt(_serial);
+		}
+		
+		/**
+		 * This will load a session state log from a ByteArray.
+		 * @param input The ByteArray containing the output from seralize().
+		 */
+		public function deserialize(input:ByteArray):void
+		{
+			var version:int = input.readInt();
+			if (version != _serializationVersion)
+				throw new Error("Unsupported Weave file version");
+			
+			_prevState = input.readObject();
+			_undoHistory = input.readObject();
+			_redoHistory = input.readObject();
+			_serial = input.readInt();
+			
+			_undoActive = false;
+			_redoActive = false;
+			_saveLater = false;
+			_savePending = false;
+			
+			getCallbackCollection(this).triggerCallbacks();
+		}
 	}
 }
+import flash.net.registerClassAlias;
+import flash.utils.getQualifiedClassName;
 
 internal class LogEntry
 {
+	{ /** begin static code block **/
+		registerClassAlias(getQualifiedClassName(LogEntry), LogEntry);
+	} /** end static code block **/
+	
 	public function LogEntry(id:int, forward:Object, backward:Object)
 	{
 		this.id = id;


package weave.core
{
	import mx.utils.ObjectUtil;
	
	import weave.api.WeaveAPI;

			saveDiff(true);
		}
		
		/**
		 * This will undo a number of steps from the saved history.
		 * @param numberOfSteps The number of steps to undo.
		 */
		public function undo(numberOfSteps:int = 1):void
		{
			applyDiffs(-numberOfSteps);
		}
		
		/**
		 * This will redo a number of steps that have been previously undone.
		 * @param numberOfSteps The number of steps to redo.
		 */
		public function redo(numberOfSteps:int = 1):void
		{
			applyDiffs(numberOfSteps);
		}
		
		/**
		 * @private
		 * @param delta The number of steps to undo (negative) or redo (positive).
		 */
		private function applyDiffs(delta:int):void
		{
			var stepsRemaining:int = Math.min(Math.abs(delta), delta < 0 ? _undoHistory.length : _redoHistory.length);
