To use this high-level interface, you need to instantiate the SWX class.
Modify the code listing so that it matches the one below:
import org.swxformat.SWX; var swx:SWX = new SWX(); swx.gateway = "http://localhost:8888/php/swx.php"; swx.encoding = "GET"; swx.debug = true; var callParameters:Object = { serviceClass: "Calculator", method: "addNumbers", args: [35, 7], result: [this, resultHandler] } swx.call(callParameters); function resultHandler(event:Object) { status.text = event.result; }
When you run the above example, you should again see 42 in the status text field. Let's look at what has changed.
The biggest change is that you are actually instantiating the SWX class and setting certain properties there (such as the gateway URL, encoding method and whether you want debug information for calls).
Instead of putting call-related parameters directly into a movie clip (you can delete the dataHolder movie clip now as you aren't using it any more), you create a callParameters object and specify the serviceClass, method, and args properties there. But you can do more, you can also specify a result handler that will get called once the data has loaded.
The result handler receives an event object as an argument. That event object has a result property that points to the loaded data.

Hi Aral! You rock and supercool man!
I read thorough this blog and I cannot be more agree with you about the idea of simplicity.
I just know this SWX for 1 week ( can you believe it), after herendous searching for month over the best way to work with database.
(Ok, I think I am over excited with this cool thing…)
I really need your help Aral related with this post (Instantiating the SWX class).
I use this service : http://swx-wordpress.artillery.ch/?page_id=8
But I simply still confused how to use it in flash. Unlike your example here, there are several method available starting from “getVars” to “getTags”.
1. How can I use the each method in flash independently, let’s say I put it in several buttons and each buttons correspond with the method respectively?
Should I write this code over and over and only change the method?
var callParameters:Object =
{
serviceClass: “Calculator”,
method: “addNumbers”,
args: [35, 7],
result: [this, resultHandler]
}
2. I know the SEARCH method is not available in those service. Do u think that kind of method is possible to implement.
Oh Aral….I’m very happy with this SWX. Thanks a lot…When are you going to speak in Sydney?