User Guide

Table Of Contents
Using the Flash Remoting service with ColdFusion pages 815
In this example, the query results are filtered by the value of Flash.paramName, which references
the first parameter in the passed array. If the parameters were passed as an ordered array from the
Flash application, you use standard structure name syntax; for example:
<cfset Flash.Result = "Variable 1:#Flash.Params[1]#, Variable 2:
#Flash.Params[2]#">
Tip: ActionScript array indexes start at zero. ColdFusion array indexes start at one.
Returning results to Flash
In ColdFusion pages, only the value of the
Flash.Result variable is returned to the Flash
application. For more information about supported data types between ColdFusion MX and
Flash, see the data type table in “Using the Flash Remoting service with ColdFusion pages
on page 812. The following procedure creates the service function
helloWorld, which returns a
structure that contains simple messages to the Flash application.
To create a ColdFusion page that passes a structure to a Flash application:
1.
Create a folder in your web root, and name it helloExamples.
2.
Create a ColdFusion page, and save it as helloWorld.cfm in the helloExamples directory.
3.
Modify helloWorld.cfm so that the CFML code appears as follows:
<cfset tempStruct = StructNew()>
<cfset tempStruct.timeVar = DateFormat(Now ())>
<cfset tempStruct.helloMessage = "Hello World">
In the example, two string variables are added to a structure; one with a formatted date and
one with a simple message. The structure is passed back to the Flash application using the
Flash.Result variable.
<cfset Flash.Result = tempStruct>
4.
Save the file.
Remember, the directory name is the service address. The helloWorld.cfm file is a method of the
helloExamples Flash Remoting service. The following ActionScript example calls the
helloWorld ColdFusion page and displays the values that it returns:
import mx.remoting.*;
import mx.services.Log;
import mx.rpc.*;
// Connect to helloExamples service and create the howdyService service object
var howdyService:Service = new Service(
"http://localhost/flashservices/gateway",
null,
"helloExamples",
null,
null );
// Call the service helloWorld() method
var pc:PendingCall = howdyService.helloWorld();
// Tell the service what methods handle result and fault conditions
pc.responder = new RelayResponder( this, "helloWorld_Result",
"helloWorld_Fault" );