<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
				horizontalAlign="center" verticalAlign="middle"
				initialize="initApp()">
	
	<mx:RemoteObject id="remoteObj" destination="echo" endpoint="http://localhost:8000">
    	<mx:method name="echo" result="onResult(event)" fault="onFault(event)"/>
 	</mx:RemoteObject>
 			
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
		    
	        public function initApp(): void
	        {
	            // This var holds the data we want to pass to the remote service.
	            var param:String = "Hello World!";
	            
	            // Call remote service to fetch data
	            remoteObj.echo( param );
	        }
	
	        // Result handler method 
	        private function onResult( re:ResultEvent ): void
	        {
	            var myData:String = re.result as String;
	            trace( myData ); // prints "Hello World!"
	            status_txt.text = myData;
	        }
	        
	        // Fault handler method displays error message 
	        private function onFault( fault:FaultEvent ): void
	        {
	            // Notify the user of the problem
	            status_txt.text = "Remoting error: \n";
	            for ( var d:String in fault.fault ) {
	               status_txt.text += fault.fault[d] + "\n";
	            }
	        }
		]]>
	</mx:Script>
	
	<mx:TextArea id="status_txt" fontWeight="bold" width="100%" height="100%"/>
	
</mx:Application>
