Using ColdFusion Data Structures in Flash Remoting
Now that ColdFusion developers are getting into Flash Remoting the questions are coming, the latest:
"How can I use the data structures that I'm used to in CF within a Flash Remoting application on the Flash side?"
Originally posted on the Daemon blog, I've put together a CFC/Flash combo to demonstrate this, including making the most of looping over the structures.
Ok, so we could come up with a variety of complex data types in development.
Let's think about some of the possibilities:
- Array
- Structure (sometimes known as an associative array)
- Query
- Complex structure (e.g. array embedded in key)
- Complex array (e.g. query or structure embedded in index)
I've created a CFC that creates each of these and a Flash movie that, via Flash Remoting, calls all these data types, then processes and outputs the values recieved.
You can download the CFC, FLA and other files from here (18 kb).
An interesting observation about structures and how the keys are named.
In ColdFusion MX we can choose to name a structure key using either array syntax or dot notation, if you choose to use array syntax the original case of the key will be preserved when transmitted to Flash via Flash Remoting a feature that is new to ColdFusion MX.
Dot notation returns the keys as all capital letters, something most developers would be familiar with.

Structure keys created with array syntax.

NetConnection Debugger output for above structure.

Structure keys created with dot notation.

NetConnection Debugger output for above structure.
A small reminder to ColdFusion developers, when it comes to arrays we're in a special category. The first index of an array is usually 1, but for the rest of the world it's 0, the Flash Remoting process does the conversion of index numbering automatically for us.
If you look at the two examples immediately above you'll note that in the CFML the structure is being embedded into the second index of an array, yet in the debug it's sitting in the first index.
Andrew

