Contents > Developing ColdFusion MX Applications > Using the Flash Remoting Service > Using the Flash Remoting service with ColdFusion pages > Accessing parameters passed from Flash PreviousNext

Accessing parameters passed from Flash

To access variables passed from Flash movies, you append the parameter name to the Flash scope or use the Flash.Params array. Depending on how the values were passed from Flash, you refer to array values using ordered array syntax or structure name syntax. Only ActionScript objects can pass named parameters.

For example, if you pass the parameters as an ordered array from Flash, array[1] references the first value. If you pass the parameters as named parameters, you use standard structure-name syntax like params.name.

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 describes the collections and examples:

Collection

ActionScript example

Notes

Strict array

var myArray = new Array(); 
myArray[1] = "one"; 
myArray[2] = "two"; 
myService.myMethod(myArray);

The Flash Remoting service converts the array argument to a ColdFusion MX array. All CFML array operations work as expected.

Named or associative array

var myStruct = new Array(); 
myStruct["one"] = "banana"; 
myStruct["two"] = "orange"; 

In ActionScript, named array keys are not case-sensitive.

Mixed array

var myMixedArray = new Array();
myMixedArray["one"] = 1; 
myMixedArray[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. The following ColdFusion component example throws an exception:

<cfargument name="ca" type="struct">

<cfreturn ca.2>

The following ColdFusion component example 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 a ColdFusion MX-based Flash Remoting service. You can access these arguments in ColdFusion pages as members of the Flash scope, or as normal named arguments of a ColdFusion component function

The Flash.Params array retains the order of the parameters as they were passed to the function. You use standard structure name syntax to reference the parameters; for example:

<cfquery name="flashQuery" datasource="exampleapps" dbtype="ODBC">
   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, which references the first parameter in the array. If the parameters were passed as an ordered array from Flash, you use standard structure name syntax; for example:

<cfset flash.result = "Variable 1:#Flash.params[1]#, Variable 2: #Flash.params[2]#">

In this ActionScript example, notice that ActionScript starts the array index at zero. ColdFusion array indexes start at one.


Contents > Developing ColdFusion MX Applications > Using the Flash Remoting Service > Using the Flash Remoting service with ColdFusion pages > Accessing parameters passed from Flash PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/usingsa5.htm