main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#FFFFFF" viewSourceURL="srcview/index.html">
<mx:Button x="250" y="157" label="sayHello" width="79" click="myservice.sayHello.send();" />
<mx:Button x="97" y="157" label="test fault" click="myservice.foo.send();"/>
<mx:TextArea x="10" y="36" width="239" height="113" id="result_text"/>
<mx:Script>
<![CDATA[
import mx.managers.CursorManager;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
private function faultHandler(fault:FaultEvent):void
{
CursorManager.removeBusyCursor();
result_text.text = "code:
" + fault.fault.faultCode + "
Message:
" + fault.fault.faultString + "
Detail:
" + fault.fault.faultDetail;
}
private function resultHandler(evt:ResultEvent):void
{
result_text.text = evt.message.body.toString(); // same as: evt.result.toString();
}
]]>
</mx:Script>
<mx:RemoteObject id="myservice" fault="faultHandler(event)" showBusyCursor="true" source="tutorials.HelloWorld" destination="amfphp">
<mx:method name="sayHello" result="resultHandler(event)" />
<mx:method name="foo" result="resultHandler(event)" />
</mx:RemoteObject>
<mx:Label x="10" y="10" text="amfphp"/>
</mx:Application>