Creating Responder Functions
You’ve seen different ways of creating a responder function for a remote service call. There are two broad categories of responder functions:
The responder functions can be methods named onResult( ) and onStatus( ) (or, more accurately, they are functions assigned to the
onResultandonStatusproperties of a responder object).Responder functions can also be named functions, in which case the function name must match the name of the remote method followed by _Result or _Status, such as
methodname_Result( ) andmethodname_Status( ). This approach is used in some of the Macromedia documentation and in Example 3-8.
Now that you understand the basics, here is the twist. A responder object can be passed to getService( ), in which case the same responder object is used for all future method invocations on that service. Alternatively, a responder object can be passed separately each time a method is invoked on the service, in which case a responder object should not be passed in the initial call to getService( ).
Using onResult( ) and onStatus( ) Responder Functions
Let’s first look at passing a responder object to
getService( ). Recall the syntax for calling the
getService( ) method, where
myConnection_conn is a
NetConnection object returned by an earlier call
to createGatewayConnection( ):
myService =myConnection_conn.getService(serviceName[,responderObject]);
The first parameter, serviceName, is a
service name such as com.oreilly.frdg.HelloWorld. The ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access