User Guide

Table Of Contents
Using server-side ActionScript functions 827
To create a Flash Remoting service connection:
1.
Include the necessary ActionScript classes in the first frame of the Flash movie that will be using
server-side ActionScript functions.
a
Use the following command to include the NetServices class:
#include "NetServices.as"
b
(Optional) Use the following command to include the NetDebug class:
#include "NetDebug.as"
For more information about the NetDebug and RecordSet classes, see Using Flash Remoting
MX.
2.
Since the Flash Remoting service serves as a broker for calls to server-side ActionScript
functions, you must identify the Flash Remoting service URL as an argument in the
NetServices.setDefaultGatewayUrl function. For example:
NetServices.setDefaultGatewayURL("http://localhost:8500/flashservices")
You must specify a server hostname. The default port number for the Flash Remoting service is
8500.
3.
Create the gateway connection using the NetServices.createGatewayConnection function;
for example:
gatewayConnection = NetServices.createGatewayConnection();
Using server-side ActionScript functions
After you connect to the Flash Remoting service, you call functions that are defined in your
server-side ActionScript files, and return results.
To call a function:
1.
Create an instance of the server-side ActionScript file using the getService function. This
function instantiates the server-side ActionScript file as an object to be used on the client side.
For example:
albumService = gatewayConnection.getService("recordsettest", this)
Where recordsettest represents the name of the server-side ActionScript file, without the
file extension
.asr.
2.
Call a function defined in your server-side ActionScript object. Use dot notation to specify the
object name followed by the function name; for example:
albumService.getAlbum("The Color And The Shape", "1999");
Where albumService is the instance of the server-side ActionScript file and getAlbum is a
function that passes two arguments,
"The Color and The Shape" and "1999".
Note: Arguments must occur in the order defined in the function declaration.
3.
Handle the function results in ActionScript. See “Using the function results in ActionScript
on page 828.