Using Flash Remoting with ColdFusion components
107
The order in which you specify the
cfargument
tags in the function corresponds to the order in
which the parameters are passed from ActionScript. For example, the following ActionScript call
passes three parameters:
CFCService.functA(a, b, c);
The corresponding ColdFusion component defines three arguments, including the data type of
the parameter:
<cfcomponent>
<cffunction ...>
<cfargument name="arg_for_a" type="type_of_a">
<cfargument name="arg_for_b" type="type_of_b">
<cfargument name="arg_for_c" type="type_of_c">
</cffunction ...>
</cfcomponent>
For information on how ActionScript data types are converted to ColdFusion data types, see
Chapter 4, “Using Flash Remoting Data in ActionScript,” on page 63
.
The following table describes using the
cfargument
tag to access parameters:
Collection
ActionScript example
Notes
Strict array
var myArray:Array = new Array();
myArray[0] = "zero";
myArray[1] = "one";
myService.myMethod(myArray);
The Flash Remoting service converts the
array argument to a ColdFusion MX array. All
CFML array operations work as expected.
<cffunction ...>
<cfargument name="arg1" type="array">
<cfset p1=arg1[1]>
<cfset p2=arg1[2]>
</cffunction ...
>
Named or
associative
array
var myStruct:Array = new Array();
myStruct["zero"] = "banana";
myStruct["one"] = "orange";
myService.myMethod(myStruct);
In ActionScript, named array keys are not
case sensitive.
<cffunction ...>
<cfargument name="arg1" type="struct">
<cfset p1=arg1.zero>
<cfset p2=arg1.one>
</cffunction ...
>
Named
arguments
using object
initializer
myService.myMethod({x:1, y:2,
z:3});
Provides a convenient way of passing named
arguments to ColdFusion pages. Access
these arguments as normal named
arguments of a component function.
<cffunction ...>
<cfargument name="x" type="numeric">
<cfargument name="y" type="numeric">
<cfargument name="z" type="numeric">
<cfset p1=x>
<cfset p2=y>
<cfset p3=z>
</cffunction ...>