
654
Chapter 30: 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 654
•
How to reference server-side ActionScript functions and methods. See
“Using server-side
ActionScript functions” on page 655
.
•
How to code the server-side
CF.query
and
CF.http
functions. See
“Using the CF.query
function” on page 658
and
“Using the CF.http function” on page 664
. Also see the reference
pages for these functions in the
CFML Reference
.
For additional information on using Flash Remoting MX, see
Chapter 29, “Using the Flash
Remoting Service,” on page 641
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.
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
.
Summary of Contents for COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Page 1: ...Developing ColdFusion MX Applications...
Page 22: ...22 Contents...
Page 38: ......
Page 52: ...52 Chapter 2 Elements of CFML...
Page 162: ......
Page 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Page 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Page 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Page 266: ......
Page 314: ...314 Chapter 14 Handling Errors...
Page 344: ...344 Chapter 15 Using Persistent Data and Locking...
Page 349: ...About user security 349...
Page 357: ...Security scenarios 357...
Page 370: ...370 Chapter 16 Securing Applications...
Page 388: ...388 Chapter 17 Developing Globalized Applications...
Page 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Page 410: ......
Page 426: ...426 Chapter 19 Introduction to Databases and SQL...
Page 476: ...476 Chapter 22 Using Query of Queries...
Page 534: ...534 Chapter 24 Building a Search Interface...
Page 556: ...556 Chapter 25 Using Verity Search Expressions...
Page 558: ......
Page 582: ...582 Chapter 26 Retrieving and Formatting Data...
Page 668: ......
Page 734: ...734 Chapter 32 Using Web Services...
Page 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Page 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Page 788: ......