User Guide

Table Of Contents
70 Chapter 4: Using Flash Remoting Data in ActionScript
If a ColdFusion page or CFC returns a numeric value without specifically identifying the value as
numeric, Flash Remoting treats the value as a string when passing it to the responder. For
example, if you have the following user-defined function and ActionScript code, Flash displays
22, not 4, in the trace message:
ColdFusion
<cffunction name="getNumber"access="remote">
<cfreturn 2>
</cffunction>
ActionScript
function getNumber_Result (result)
{
myVar = (result + 2);
trace (myVar);
}
To prevent such problems, do either of the following:
Specify the returnType="numeric" attribute in the cffunction tag, as in the following
example:
<cffunction name="getNumber" access="remote" returnType="numeric">
<cfset foo = 2>
<cfreturn foo>
</cffunction>
Use the Val function to explicitly convert the value to a number before you return it, as in the
following example:
<cffunction name="getNumber" access="remote">
<cfset foo = Val(2)>
<cfreturn foo>
</cffunction>
If you call either of these getNumber() functions from Flash, the ActionScript
getNumber_Result() function in the previous example displays the value 4.
About working with objects
When you pass a Flash object in a service function call, the object’s properties are sent to the
gateway. In Java environments, an instance of the
flashgateway.io.ASObject class (which
implements java.util.Map) represents a Flash object. In .NET environments, an instance of the
FlashGateway.IO.ASObject class (which implements the ICollection interface) represents a
Flash object. Therefore, you can pass Flash objects to any service function that accepts a Map or
ICollection argument.
Because Flash Remoting transmits data only, the object methods are not available on the server.
Similarly, the object properties must be data types that Flash Remoting can handle. For example,
you cannot include a Flash RecordSet object in an object that you pass to a service function,
because Flash Remoting cannot convert the RecordSet object to a data type on the server.