User Guide

Table Of Contents
816 Chapter 33: Using the Flash Remoting Service
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
1 to indicate true, and return 0 to indicate false.
Returning records in increments to Flash
ColdFusion MX lets you return record set results to Flash in increments. For example, if a query
returns 20 records, you can set the
Flash.Pagesize variable to return five records at a time to
Flash. Incremental record sets let you minimize the time that a Flash application waits for the
application server data to load.
To create a ColdFusion page that returns a incremental record set to Flash:
1.
Create a ColdFusion page, and save it as getData.cfm in the helloExamples directory.
2.
Modify getData.cfm so that the code appears as follows:
<cfparam name="pagesize" default="10">
<cfif IsDefined("Flash.Params")>
<cfset pagesize = Flash.Params[1]>
</cfif>
<cfquery name="myQuery" datasource="cfdocexamples">
SELECT *
FROM tblParks
</cfquery>
<cfset Flash.Pagesize = pagesize>
<cfset Flash.Result = myQuery>
In this example, if a single parameter is passed from the Flash application, the pagesize
variable is set to the value of the
Flash.Params[1] variable; otherwise, the value of the
variable is the default, 10. Next, a
cfquery statement queries the database. After that, the
pagesize variable is assigned to the Flash.Pagesize variable. Finally, the query results are
assigned to the
Flash.Result variable, which is returned to the Flash application.
3.
Save the file.