Connecting to the Flash Remoting service

Before you can use functions defined in your server-side ActionScript, you must first perform several initial set up tasks.

First, you connect the Macromedia Flash movie to the server-side Flash Remoting service. The following steps create a Flash Remoting service connection:

  1. Include NetServices.as in your Flash movie.
  2. Specify the default Flash Remoting service URL and create a connection to the service.

See the following sections for more details:

After you perform this setup, you can use the functions defined in your server-side ActionScript.

Including the necessary ActionScript classes

You must include a series of ActionScript classes in the first frame of the Flash movie that will be using server-side ActionScript functions. The following command includes the NetServices class:

#include "NetServices.as"

The following command includes the NetDebug class:

#include "NetDebug.as"

The NetServices include statement is required for server-side ActionScript. The NetDebug include statement is optional.

Establishing a connection to the Flash Remoting service

The Flash Remoting service serves as a broker for calls to server-side ActionScripts.

To use server-side ActionScript:

  1. Identify the Flash Remoting service URL as an argument in the NetServices.setDefaultGatewayUrl function; for example:
    NetServices.setDefaultGatewayURL("http://localhost:8100/flashservices")
    

    You must specify a ColdFusion MX Server hostname. The default port number for the Flash Remoting service is 8100.

  2. Create the gateway connection using the NetServices.createGatewayConnection function; for example:
    gatewayConnection = NetServices.createGatewayConnection();
    

Comments