User Guide

Table Of Contents
814 Chapter 33: Using the Flash Remoting Service
You can use most of the CFML array and structure functions on ActionScript collections.
However, the
StructCopy CFML function does not work with ActionScript collections. The
following table lists ActionScript collections and describes how to access them in
ColdFusion MX:
The
Flash.Params array retains the order of the parameters as they were passed to the method.
You use standard structure name syntax to reference the parameters; for example:
<cfquery name="flashQuery" datasource="cfdocexamples">
SELECT ItemName, ItemDescription, ItemCost
FROM tblItems
WHERE ItemName EQ '#Flash.paramName#'
</cfquery>
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.
<cfset p1=Flash.Params[1][1]>
<cfset p2=Flash.Params[1][2]>
Named or
associative array
var myStruct:Array = new Array();
myStruct["zero"] = "banana";
myStruct["one"] = "orange";
myService.myMethod(myStruct);
Named array keys are not case-sensitive
in ActionScript.
<cfset p1=Flash.Params[1].zero>
<cfset p2=Flash.Params[1].one>
Mixed array
var myMxdArray:Array = new Array();
myMxdArray["one"] = 1;
myMxdArray[2] = true;
Treat this collection like a structure in
ColdFusion MX. However, keys that
start with numbers are invalid CFML
variable names. Depending on how you
attempt to retrieve this data,
ColdFusion MX might throw an
exception. For example, the following
CFC method throws an exception:
<cfargument name="ca" type="struct">
<cfreturn ca.2>
The following CFC method does not
throw an exception:
<cfargument name="ca" type="struct">
<cfreturn ca["2"]>
Using an
ActionScript
object initializer
for named
arguments
myService.myMethod
({ x:1, Y:2, z:3 });
This notation provides a convenient way
of passing named arguments to
ColdFusion pages. You can access
these arguments in ColdFusion pages
as members of the Flash scope:
<cfset p1 = Flash.x>
<cfset p2 = Flash.y>
<cfset p3 = Flash.z>
Or, you can access them as normal
named arguments of a CFC method.