User Guide

Understanding application flow 31
Invoking remote methods
After a successful connection, the client can invoke remote methods that the server
component defines; the server application can also remotely invoke ActionScript methods
defined in the Flash client application.
Invoking server methods from the client
Each Flash application that connects to a server application is represented by a Client object,
which is an instance of the server-side Client class. Each Client object, in turn, can have
developer-defined methods associated with it that are accessible remotely. (You can also use
the
prototype property to create remote methods available to all clients. For an example of
this, see the Client class entry in the Server-Side ActionScript Language Reference.
A Flash application can then use the
NetConnection.call() method to call the remotely
defined method, and optionally specify a callback object to handle the result that the server
returns. On the server, the method corresponding to the client call is invoked, and a result is
returned to the client.
The following diagram illustrates an example of invoking a server-defined method from a
client. In the diagram, the client invokes the
doThis remote method over the NetConnection
object named
nc. The doThis method is associated with a Client object, called clientObj in
this case, that represents the client.
Remote method call flow from client to server, with result passed back to client
CLIENT
call("doThis",
callback_obj,a,b)
onResult
"doThis",a,b
resultObj
SERVER
clientObj.doThis(a,b)