Adobe COLDFUSION 9 Manual page 619

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
2
Create a ColdFusion page, and save it as helloWorld.cfm in the helloExamples directory.
Modify helloWorld.cfm so that the CFML code appears as follows:
3
<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 SWF application using the
<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
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" );
function helloWorld_Result(re:ResultEvent)
{
// Display successful result
messageDisplay.text = re.result.HELLOMESSAGE;
timeDisplay.text = re.result.TIMEVAR;
}
function helloWorld_Fault(fe:FaultEvent)
{
// Display fault returned from service
messageDisplay.text = fe.fault;
}
Note: Due to ActionScript's automatic type conversion, do not return a Boolean literal to Flash from ColdFusion. Return
to indicate
, and return
1
true
Returning records in increments to Flash
ColdFusion lets you return record set results to Flash in increments. For example, if a query returns 20 records, you
can set the
Flash.Pagesize
the time that a SWF application waits for the application server data to load.
Create a ColdFusion page that returns an incremental record set to Flash
Create a ColdFusion page, and save it as getData.cfm in the helloExamples directory.
1
to indicate
.
0
false
variable to return five records at a time to Flash. Incremental record sets let you minimize
Last updated 8/5/2010
variable.
Flash.Result
helloExamples
614
Flash

Advertisement

Table of Contents
loading

Table of Contents