User Guide

Table Of Contents
826 Chapter 34: Using Server-Side ActionScript
You could, for example, create a server-side ActionScript file that defines a whole library of SQL
query methods. With these query methods defined on the server side, your Flash designers only
have to invoke the specific query function they want to return data to their Flash MX movies.
They do not have to write any SQL, and they do not have to create a new query every time they
need to retrieve data from a ColdFusion MX data source. It is a way of creating reusable queries
that your entire Flash design team can use.
Coding the ColdFusion MX query and HTTP operations in ActionScript is very straightforward.
The
CF.query and CF.http functions provide a well-defined interface for building SQL queries
and HTTP operations.
For example, the following is a typical server-side ActionScript function definition that returns
query data:
// This function shows a basic CF.query operation using only
// arguments for data source name and for SQL.
function basicQuery()
{
mydata = CF.query({datasource:"customers",
sql:"SELECT * FROM myTable"});
return mydata;
}
What to do next
If you are already familiar with ActionScript, you only need to know a few things to get started:
How to establish a connection with the Flash Remoting service using client-side ActionScript.
See “Connecting to the Flash Remoting service” on page 826
How to reference server-side ActionScript functions and methods. See “Using server-side
ActionScript functions” on page 827.
How to code the server-side CF.query and CF.http functions. See “Using the CF.query
function” on page 831 and “Using the CF.http function” on page 837. Also see the reference
pages for these functions in the CFML Reference.
For additional information on using Flash Remoting MX, see Chapter 33, “Using the Flash
Remoting Service,” on page 807, and Using Flash Remoting MX.
Connecting to the Flash Remoting service
Before you can use functions defined in your server-side ActionScript files, you must connect the
Macromedia Flash MX movie to the server-side Flash Remoting service.