O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

20.12. Passing Complex Parameters to ColdFusion Component Methods

Problem

You want to pass an object parameter to a ColdFusion Component (CFC) method using Flash Remoting.

Solution

Pass the value as a named parameter.

Discussion

ColdFusion automatically attempts to convert object parameters into named parameters (see Recipe 20.11). This is problematic if you want to pass an ActionScript object to a CFC method as a parameter. Consider the following example:

<!--- A sample CFC method definition --->
<cffunction name="insertCatalogItem" access="remote">
  <cfargument name="catalogItem" type="struct">
  <!--- rest of method body --->
<cffunction>

// The corresponding ActionScript snippet . . . 

// Create an item object with name, price, and description properties.
item = new Object(  );
item.name = "Widget";
item.price = 9.99;
item.description = "Widgets available in green, blue, and gold";

// Call the insertCatalogItem(  ) service function and pass it the item object.
myService.insertCatalogItem(myResponseObject, item);

In the preceding example, we want to pass the item object from Flash to the CFC method as a parameter that should be converted into a struct (a complex datatype). However, ColdFusion attempts to convert the properties of the item object into named parameters, and it tries to match up the name, price, and description properties to corresponding parameters within the CFC method. This prevents it from successfully passing a complex parameter, such as an object datatype.

You should ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required