
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
.
Содержание COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...