Listing 1

   HistoryWindow.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
	implements="mx.managers.IHistoryManagerClient"
	creationComplete="initPanel()"
	move="doMove()"
	mouseUp="doMouseUp()"
	width="200" height="150"
backgroundColor="#FFFFFF"
cornerRadius="8"
	horizontalAlign="center">

	<mx:Script>
		<![CDATA[
			import mx.effects.Move;
			import mx.managers.HistoryManager;
		
			private var changed : Boolean;

			public function initPanel() : void
{
				x = 0;
				y = 0;
				HistoryManager.register( this );
				storeInternalState();
			}
			
			public function saveState() : Object
{
				// called by HistoryManager, tells the component
				// to create a "state" object and to return it
				return { xPos:x, yPos:y };
			}
			
			public function loadState( state : Object ) : void
{
				// called by HistoryManager, passes in a state
				// object so the component can rebuild it's state
				if( state != null )
				{
					restoreInternalState( state );
				}
			}
			
			private function doMove() : void
{
				changed = true;
			}
			
			private function doMouseUp() : void
{
				if ( changed ) storeInternalState();
			}
			
			private function storeInternalState() : void
{
				HistoryManager.save();
				changed = false;
			}
			
			private function restoreInternalState( state : Object ) : void
{
				var mover : Move = new Move( this );
				mover.xTo = state.xPos;
				mover.yTo = state.yPos;
				mover.play();
			}
		
		]]>
	</mx:Script>

	<mx:Text text="Just move me around, use the browser's buttons to restore state."
selectable="false"
width="100%"
fontSize="12"/>

</mx:TitleWindow>
Main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
		initialize="initApp()">

	<mx:Script>
	<![CDATA[
		import mx.managers.PopUpManager;
		
		public function initApp() : void
{
			PopUpManager.createPopUp( this, HistoryPanel, false );
			PopUpManager.createPopUp( this, HistoryPanel, false );
		}
	]]>
	</mx:Script>
	
</mx:Application>

Listing 2

StockQuote.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
		implements="mx.managers.IHistoryManagerClient"
		initialize="mx.managers.HistoryManager.register( this );">

	<mx:Script>
		<![CDATA[
			import mx.managers.HistoryManager;
			
			public function saveState() : Object
			{
				var state : Object = new Object();
				state.symbol = symbol.text;
				return state;
			}
			public function loadState( state : Object ) : void
			{
				if (state != null && state.symbol != null ){
					symbol.text = state.symbol;
					ws.getQuote.send();
				}
			}
			public function getQuote() : void
			{
				ws.getQuote.send();
				HistoryManager.save();
			}
		]]>
	</mx:Script>

	<mx:WebService id="ws"
		wsdl="http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl"
		useProxy="false">
		<mx:operation name="getQuote">
			<mx:request>
				<symbol>{ symbol.text }</symbol>
			</mx:request>
		</mx:operation>
	</mx:WebService>

	<mx:Label text="Enter a symbol:"/>

	<mx:HBox>
		<mx:TextInput id="symbol" width="60"/>
		<mx:Button label="Get Quote" click="getQuote()"/>
	</mx:HBox>

	<mx:Label text="{ ws.getQuote.lastResult }"
fontSize="24"
fontWeight="bold"/>

</mx:Application>