Using server-side ActionScript functions
655
2
Since the Flash Remoting service serves as a broker for calls to server-side ActionScript
functions, you must identify the Flash Remoting service URL as an argument in the
NetServices.setDefaultGatewayUrl
function. For example:
NetServices.setDefaultGatewayURL("http://localhost:8500/flashservices")
You must specify a server hostname. The default port number for the Flash Remoting service is
8500.
3
Create the gateway connection using the
NetServices.createGatewayConnection
function;
for example:
gatewayConnection = NetServices.createGatewayConnection();
Using server-side ActionScript functions
After you connect to the Flash Remoting service, you call functions that are defined in your
server-side ActionScript files, and return results.
To call a function:
1
Create an instance of the server-side ActionScript file using the
getService
function. This
function instantiates the server-side ActionScript file as an object to be used on the client side.
For example:
albumService = gatewayConnection.getService("recordsettest", this)
Where
recordsettest
represents the name of the server-side ActionScript file, without the
file extension
.asr
.
2
Call a function defined in your server-side ActionScript object. Use dot notation to specify the
object name followed by the function name; for example:
albumService.getAlbum("The Color And The Shape", "1999");
Where
albumService
is the instance of the server-side ActionScript file 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.
3
Handle the function results in ActionScript. See
“Using the function results in ActionScript”
on page 655
.
Using the function results in ActionScript
To use the results returned by server-side ActionScript, you must create a corresponding
results
function
. The results function uses a special naming convention that ties it to the function that
calls the server-side ActionScript. For example, if you defined a client-side ActionScript function
called
basicCustomerQuery
, you also must create a results function called
basicCustomerQuery_Result
.
The results returned by server-side ActionScript functions differ somewhat depending on whether
you are using
CF.http
or
CF.query
:
•
The
CF.query
function returns a record set, which you manipulate using methods available in
the RecordSet ActionScript class object. See
“Using results returned by the CF.query function”
on page 656
.
•
The
CF.http
function returns simple text strings through properties that you reference in your
server-side ActionScript. See
“Using results returned by the CF.http function” on page 656
.
Summary of Contents for 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: ......