Using Flash Remoting with ColdFusion components
105
When you assign a value to the
Flash.Pagesize
variable, you specify that if the record set has
more than that number of records, the record set becomes pageable and returns the number of
records specified in the
Flash.Pagesize
variable. For example:
import mx.remoting.Service;
import mx.remoting.PendingCall;
//…
var CFMService:Service = new Service(
"http://localhost/flashservices/gateway",
null,
"helloExamples",
null,
null);
var pc:PendingCall = CFMService.getData(10);
//…
Flash UI components are designed to recognize results returned in increments. After the initial
delivery of records, the RecordSet ActionScript class assumes the task of fetching records. You can
configure the client-side RecordSet object to fetch records in various ways using the
RecordSet.setDeliveryMode()
ActionScript function.
In many cases, you do not have to modify the Flash UI components to handle data returned in
increments. For example, if the record set is returned to a Flash list box, the list box requests more
rows as the user scrolls through the list box.
Using Flash Remoting with ColdFusion components
ColdFusion components require little modification to work with Flash. The
cffunction
tag
names the function and contains the application logic, and the
cfreturn
tag returns the result
to Flash.
Determining the Flash service name
The service name in ActionScript corresponds to the name of the CFC file that contains the
ColdFusion component. For example, if you create a ColdFusion component in the file
flashComp.cfc, and the file is located in the directory helloExamples under your web root
directory, you would define the service in ActionScript as follows:
import mx.remoting.Service;
var CFCService:Service = new Service(
"http://localhost/flashservices/gateway",
null,
"
helloExamples.flashComp
",
null,
null);
Within ColdFusion components, you create functions that define the functionality of the
component. After defining the ActionScript service, you call component functions directly from
ActionScript. For example, the following component defines two functions:
<cfcomponent>
<cffunction name=
"functA"
access=
"remote"
returnType="Struct">