ColdFusion struct properties converted to uppercase when using Flash Remoting

| 1 Comment | No TrackBacks

If you've ever passed a struct from ColdFusion to Flash via Flash Remoting, you've probably noticed that all of the keys for the struct come into Flash as uppercase. In the past, this wasn't that big of a deal, but when Flash Player 7 came around with case-sensitivity, some people started to encounter problems. Here's the simple workaround...

Consider the following code:

<cfcomponent>
  <cffunction name="getSomeData" returntype="struct" access="remote">
    <cfset oData = StructNew() />
    <cfset oData.key1 = "example 1" />   <!--- converts to KEY1 --->
    <cfset oData["key2"]= "example 2" />   <!--- preserves case --->
    <cfset StructInsert(oData, "key3", "example 3") /> <!--- preserves case --->
    <cfreturn oData />
  </cffunction>
</cfcomponent>

Note that accessing a struct in the "usual" way with dot notation will convert the key to all uppercase. By using array (bracket) notation, you can preserve the case of the key. Additionally, if you use the StructInsert function you can also preserve the case of the key.

I hope this post saves someone some debugging time in the future. This question recently came up on a mailing list, so hopefully google will find this post and make the answer easier to locate. :-)

No TrackBacks

TrackBack URL: http://www.darronschall.com/mt/mt-tb.cgi/14

1 Comment

That's very helpful Darron. Very cool, thanks, Matt.

Leave a comment



About this Entry

This page contains a single entry by darron published on August 15, 2004 7:09 PM.

Flash Quirk: Disabled buttons still broadcast click was the previous entry in this blog.

Anonymous, inline, and named functions in ActionScript is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Archives

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.02