
613
DEVELOPING
COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Las
t
upda
te
d 8/5/2010
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>
In this example, the query results are filtered by the value of
Flash.paramName
, whichreferences the first parameter
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
Flash.Result
variable is returned to the SWF application. For more
information about supported data types between ColdFusion and Flash, see the data type table in “
Using the Flash
Remoting service with ColdFusion pages
” on page 611. The following procedure creates the service function
helloWorld
, which returns a structure that contains simple messages to the SWF application.
Create a ColdFusion page that passes a structure to a SWF application
1
Create a folder in your web root, and name it helloExamples.
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 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. 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"]>
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.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...