User Guide

Table Of Contents
824 Chapter 34: Using Server-Side ActionScript
You have a very simple interface for building queries using server-side ActionScript, and an
equally simple interface for invoking these queries from your client-side ActionScript.
Client-side ActionScript requirements
On the client side, you only need a small piece of code that establishes a connection to the Flash
Remoting service and references the server-side ActionScript you want to use.
For example (notice the embedded comments):
// This #include is needed to connect to the Flash Remoting service
#include "NetServices.as"
// This line determines where Flash MX should look for the Flash Remoting
service.
// Ordinarily, you enter the URL to your ColdFusion server.
// Port 8500 is the Flash Remoting service default.
NetServices.setDefaultGatewayUrl("http://mycfserver:8500");
// With the Flash Remoting service URL defined, you can create a connection.
gatewayConnnection = NetServices.createGatewayConnection();
// Reference the server-side ActionScript.
// In this case, the stockquotes script file lives in the web root of the
// ColdFusion server identified previously. If it lived in a subdirectory
// of the web root called "mydir," you would reference it
// as "mydir.stockquotes".
stockService = gatewayConnnection.getService("stockquotes", this);
// This line invokes the getQuotes() method defined in the stockquotes
// server-side ActionScript.
stockService.getQuotes("macr");
// Once the record set is returned, you handle the results.
// This part is up to you.
function getQuotes_Result ( result )
{
// Do something with results
}
Note: Client-side ActionScript does not support the two new server-side ActionScript functions,
CF.query and CF.http.
Server-side requirements
Creating ActionScript that executes on the server helps leverage your knowledge of ActionScript.
It also provides direct access to ColdFusion MX query and HTTP features. The
CF.query and
CF.http ActionScript functions let you perform ColdFusion MX HTTP and query operations.
Note: On the server side, ActionScript files use the extension .asr.