) ) MethodFlash 6

invokes a server-side method from client-side ActionScript, resultObject, arg1,...argn)



The name of the server-side method to invoke, in the format serviceName.methodName. The syntax for calling the method varies with the server technology, as described in earlier chapters.


An ActionScript object with an onResult( ) method to handle results from the call to the server-side method. You can also pass null, in which case no results are handled.

arg1, ...argn

Zero or more arguments to be passed to the remote method. The third argument passed to the call( ) method (i.e., arg1) is passed as the first argument to the remote method. The next argument, arg2, is passed as the second argument to the remote method, and so on.


Return value of the remote method is passed to the onResult( ) handler of resultObject.


The call( ) method is used to invoke a remote method through the NetConnection object. The call( ) method is not typically used directly by a developer. Instead, the developer typically uses the getService( ) method, which is a wrapper around the call( ) method that also adds more functionality. Using call( ), you have to create responder objects that contain onResult( ) and onStatus( ) methods; you can't use the named function methodname_onResult( ) or methodname_onStatus( ) techniques shown elsewhere in this book.

Because the call( ) method is a core method of the NetConnection object, you don't have to include the file in your Flash application to use it.


The following code shows the basic syntax of the call( ) method:

// Create a responder object
var myResult = new Object( );
// Create an onResult( ) method to handle results from the call to the remote method
myResult.onResult = function (result) {
  display_txt.text = result;

// Create the connection
var my_conn = new NetConnection( );
// Attach a URL for the gateway
// Call the remote method"com.oreilly.frdg.HelloUser.sayHello", myResult, firstname_txt.text);
// Nullify the connection
my_conn.close( );

In this case, a remote method named sayHello( ) in the com.oreilly.frdg.HelloUser service is invoked with one argument: firstname_txt.text. A responder object is created before calling the remote method and is passed as the second argument to call( ). The onResult( ) method of the responder object receives the response from the remote method call.

See Also

NetConnection.getService( ); Chapter 4

    Part III: Advanced Flash Remoting