Making a Remote Call

Now that we have some preliminaries out of the way, it’s time to do some Remoting! The steps for a successful Flash Remoting call to a remote service are as follows:

  1. Include the NetServices.as library.

  2. Optionally, initialize variables to hold the URL of the gateway path and the name of the remote service.

  3. Create a connection object that initializes a path to the Flash Remoting gateway.

  4. Create a service object, which will be used to invoke remote services and dispatch results and error events.

  5. Create onResult( ) and/or onStatus( ) callback methods to handle the onResult and onStatus events. These can be contained in a responder object or on the current timeline.

  6. Call the remote service as a method of the service object. The Flash movie continues to execute while waiting for the response, so your code must not assume that the results are returned immediately.

  7. When an onResult or onStatus event is returned, the appropriate callback function is triggered, and the movie reacts as programmed.

The following sections describe the preceding steps in greater detail by going through a slightly more advanced version of the HelloWorld service, called HelloUser. The HelloUser service collects a user-supplied parameter, checks the time on the server, concatenates a string, and passes the whole thing back as a result to the Flash movie. The responder object processes the results of the remote call and displays the string onscreen. This example demonstrates the following concepts ...

Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.