import org.swxformat.SWX; var swx:SWX = new SWX(); swx.gateway = "http://localhost:8888/php/swx.php"; swx.encoding = "GET"; swx.debug = true; swx.timeout = 2; // seconds var callParameters:Object = { serviceClass: "Calculator", method: "addNumbers", args: [35, 7], result: [this, resultHandler], timeout: [this, timeoutHandler], fault: [this, faultHandler] } swx.call(callParameters); function resultHandler(event:Object) { status.text = event.result; } function timeoutHandler() { status.text = "Call timed out!"; } function faultHandler(event:Object) { status.text = event.fault.message; }
And modify your class so that it generates an error:
<?php class Calculator { function addNumbers($n1, $n2) { return $n3; // $n3 does not exist! } } ?>
Test your FLA and you should get something along the lines of Error 8: Undefined variable: n3 in /htdocs/swx/trunk/php/services/Calculator.php, line 7 in the status text field in Flash.
The fault handler also returns API-specific fault codes (e.g., Flickr API error codes) back to Flash.
