Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 618

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Collection
ActionScript example
Strict array
var myArray:Array = new Array();
myArray[0] = "zero";
myArray[1] = "one";
myService.myMethod(myArray);
var myStruct:Array = new Array();
Named or associative
myStruct["zero"] = "banana";
array
myStruct["one"] = "orange";
myService.myMethod(myStruct);
Mixed array
var myMxdArray:Array = new Array();
myMxdArray["one"] = 1;
myMxdArray[2] = true;
Using an ActionScript
myService.myMethod({ x:1, Y:2, z:3 });
object initializer for
named arguments
The
array retains the order of the parameters as they were passed to the method. You use standard
Flash.Params
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>
In this example, the query results are filtered by the value of
in the passed array. If the parameters are passed as an ordered array from the SWF application, you use standard
structure name syntax; for example:
<cfset Flash.Result = "Variable 1:#Flash.Params[1]#, Variable 2: #Flash.Params[2]#">
Note: ActionScript array indexes start at zero. ColdFusion array indexes start at one.
Returning results to Flash
In ColdFusion pages, only the value of the
information about supported data types between ColdFusion and Flash, see the data type table in
Remoting service with ColdFusion
, which returns a structure that contains simple messages to the SWF application.
helloWorld
Create a ColdFusion page that passes a structure to a SWF application
Create a folder in your web root, and name it helloExamples.
1
Flash.paramName
variable is returned to the SWF application. For more
Flash.Result
pages" on page 611. The following procedure creates the service function
Last updated 1/20/2012
Notes
The Flash Remoting service converts the Array argument to a
ColdFusion array. All CFML array operations work as expected.
<cfset p1=Flash.Params[1][1]>
<cfset p2=Flash.Params[1][2]>
Named array keys are not case-sensitive in ActionScript.
<cfset p1=Flash.Params[1].zero>
<cfset p2=Flash.Params[1].one>
Treat this collection like a structure in ColdFusion. However,
keys that start with numbers are invalid CFML variable names.
Depending on how you attempt to retrieve this data,
ColdFusion sometimes throws 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"]>
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.
, whichreferences the first parameter
613
"Using the Flash

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents