Calling server-side ActionScript functions

After you connect to the Flash Remoting service, you call functions that are defined in your server-side ActionScript, and return results.

To call a functions:

  1. Create an instance of the server-side ActionScript using the getService function. This function instantiates the server-side ActionScript as an object to be used on the client side.
  2. Call a function defined in your server-side ActionScript object.
  3. Handle the function results in ActionScript.

For more information, see the following sections:

Creating an instance of the server-side ActionScript

To access the server-side ActionScript, first you must create an instance of it so it can be invoked in your client-side ActionScript. To create an instance of your server-side ActionScript, use the gatewayConnection.getService function; for example:

albumService = gatewayConnection.getService("recordsettest", this) 

In the example, recordsettest represents the name of the server-side ActionScript file, without the file extension .asr.

Calling a server-side ActionScript function

To use the functions in a server-side ActionScript, you use dot notation to specify the object name name followed by the function name; for example:

albumService.getAlbum("The Color And The Shape", "1999");

In the example, albumService is the instance of the server-side ActionScript 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.

Comments