import flash.net.NetConnection; import flash.net.Responder; // Gateway connection object private var gateway:NetConnection; public function initApp(): void { // Setup connection gateway = new NetConnection(); // Connect to gateway gateway.connect( "http://localhost:8000" ); // This var holds the data we want to pass to the remote service. var param:String = "Hello World!"; // Set responder property to the object and methods that will receive the // result or fault condition that the service returns. var responder:Responder = new Responder( onResult, onFault ); // Call remote service to fetch data gateway.call( "echo", responder, param ); } // Result handler method private function onResult( result:* ): void { var myData:String = result; trace( myData ); // prints "Hello World!" status_txt.text = myData; } // Fault handler method displays error message private function onFault( error:* ): void { // Notify the user of the problem status_txt.text = "Remoting error: \n"; for ( var d:String in error ) { status_txt.text += error[d] + "\n"; } }