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.

Hey Aral, i was just getting into SWX, and wanted to know how the progress handler works when you make a call, what parameters if recieves exactly. Thanks! SWX rocks
If you cannot send a new SWX call after a failed call, here is the solution:
function faultHandler(event:Object)
{
trace (event.fault.message);
// cancel all calls
swx.cancelAllCalls();
}
It took my a really long time to figure that there is a function called cancelAllCalls()
Before, my application just didn’t do anything after a failed call.
I just discovered this too - seems like a bug to me, since calling this code trace()’s the following error:
Warning: Cannot cancel loading clip since it has already loaded: http://blah/php/swx.php
Hi guys,
I am going to look into this. Thanks for reporting it.