Flash Remoting MX automatically converts between the data types specific to the application server programming environment and ActionScript.
The following table shows how Flash Remoting MX converts data returned from the application server to ActionScript data types:
| C# |
Visual Basic |
SOAP |
ColdFusion MX |
Java |
ActionScript |
|---|---|---|---|---|---|
| null |
Nothing |
null |
N/A |
null |
null |
| bool System.Boolean |
Boolean |
boolean |
Boolean, 0, or 1 For details, see "Boolean data in ColdFusion" |
Boolean |
Boolean |
| any number type |
any number type |
decimal, float, double |
Val(Number) For details, see "Numeric data in ColdFusion" |
Number |
Number |
| System.Char System.String |
Char String |
string |
String |
String Character |
String See "Server data conversion notes" |
| System.DateTime |
Date |
dateTime |
Date |
Date |
Date |
| System.Collections.ICollection object[] |
System.Collections.ICollection object[] |
array |
Array |
Collection Object[] array of primitive types |
Array |
| System.Collections.Hashtable System.Collections.IDictionary |
System.Collections.Hashtable System.Collections.IDictionary |
complex type |
Struct |
java.util.Map |
Associative array |
| Sytem.Data. DataSet |
Sytem.Data. DataSet |
Complex type (DataSet) |
- |
- |
Associative array of RecordSet objects |
| System.Data.Data Table |
System.Data.Data Table |
- |
Query object |
java.sql.Result Set |
RecordSet |
| - |
- |
- |
Query object (Flash.pagesize variable set) |
flashgateway. sql.Pageable ResultSet |
Paged RecordSet |
| FlashGateway.IO. ASObject System.Exception |
FlashGateway.IO. ASObject System.Exception |
Complex type |
A Java object as listed in the next column |
flashgateway.io. ASObject Serializable Dictionary Throwable |
Object |
| FlashGateway.IO. ASObject with Type property set |
FlashGateway.IO. ASObject with Type property set |
Complex type |
Java Object of class flashgateway.io. ASObject with Type property set (Set the type using a Java expression once you create the object using CFML.) |
flashgateway.io. ASObject with Type property set |
Typed Object See "Server data conversion notes" |
| System.Xml. XmlDocument |
System.Xml. XmlDocument |
- |
XML |
org.w3c.dom. Document flashgateway.io.ASXMLString |
XML |
The following is additional information on conversion from server data types to ActionScript data types:
ColdFusion is a loosely typed or "untyped" language, where the data type of a variable can be ambiguous. As a result, Flash Remoting MX cannot always determine how to convert between ColdFusion data and ActionScript data. The following sections discuss the limitations that this situation imposes, and how to prevent errors that can arise as a result.
If a ColdFusion page or CFC returns Boolean values, it represents these values as strings. Flash does not have rules for converting strings to Boolean values. Instead, it converts the string to a number, and then converts the number to a Boolean value. This operation converts all representations of Boolean values to False. Therefore Flash converts ColdFusion Boolean values of "Yes", "True", and True to False.
To return a Boolean value correctly from ColdFusion to ActionScript, do either of the following:
<cffunction name="convertBool">
<cfif Arguments[1] >
<cfreturn "1">
<cfelse>
<cfreturn "0">
</cfif>
</cffunction>
returnType="boolean" attribute in the cffunction tag, as in the following example. When a Flash application calls this ColdFusion function as a service, the function returns a valid Boolean True value to Flash.<cffunction name="getBool" access="remote" returntype="boolean">
<cfset foo = True>
<cfreturn foo>
</cffunction>
If a ColdFusion page or CFC returns a numeric value without specifically identifying the value as numeric, Flash Remoting MX 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:
<cffunction name="getNumber"access="remote">
<cfreturn 2> </cffunction>
function getNumber_Result ( result )
{
myVar = (result + 2); trace (myVar); }
To prevent such problems, do either of the following:
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>
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 displays the value 4.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flashremoting/mx/Using_Flash_Remoting_MX/UseASData4.htm
Comments
sgilson102 said on Sep 30, 2002 at 5:09 PM :