104
Chapter 6: Using Flash Remoting with ColdFusion MX
Depending on the SQL code of the query and the amount of data stored in the database, the
query can return a single record, a few records, or a very large number of records. To pass the
entire record set to the Flash application, you simply write the record set to the
Flash.Result
variable.
In ActionScript, you access the record set columns to display the query. For example, you use the
following ActionScript code to call a ColdFusion page named cfQuery.cfm that contains the
previous query:
myService.cfQuery("RipperStik");
In the result handler for the
cfQuery()
function, you access the record set as follows:
function cfQuery_Result (re:ResultEvent):Void
{
DataGlue.bindFormatStrings(employeeData, re.result, "#ItemName#,
#ItemDescription#, #ItemCost#");
}
In this example,
employeeData
is a Flash list box. This result handler displays the columns
ItemName, ItemDescription, and ItemCost from each record in the result set, separated by
commas, in the list box.
Returning record sets in increments
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
variable to return five records at a time to
Flash. Incremental record sets let you minimize the time that the Flash application waits for the
application server data to load.
The entire record set is called a
pageable record set
and each increment is called a
page
. Therefore,
the
Flash.Pagesize
variable sets the number of records in each page.
The ColdFusion page executes once and returns all the results to the Flash Remoting gateway.
The Flash application then requests subsequent records from the gateway as required.
To create a ColdFusion page that returns an incremental record set to Flash:
1.
Create a ColdFusion page, and save it as
getData.cfm
in the helloExamples directory.
2.
Modify getData.cfm as follows:
<cfset
Flash.Pagesize
= Flash.Params[1]>
<cfquery name="myQuery" datasource="ExampleApps">
SELECT ItemName, ItemDescription, ItemCost
FROM tblItems
</cfquery>
<cfset Flash.Result = myQuery>
In this example, you pass a parameter from the Flash application that defines the increment
size.
3.
Save the file.
Содержание FLASH REMOTING MX
Страница 1: ...Using Flash Remoting for Flash MX 2004 ActionScript 2 0...
Страница 8: ...8 Contents...
Страница 62: ...62 Chapter 3 Using the RemotingConnector component Flash Professional only...
Страница 142: ...142 Chapter 7 Using Flash Remoting for Java...