Is it possible to pass a structure to ColdFusion using Flash AS3 / Remoting

UPDATE: This problem has been solved. The solution is after the post.

I’ve posted on a few forums now with no results so I’m resorting to my own blog. What I’m trying to do is pass a structure to a ColdFusion component from Flash. I’ve tried using Array, Object, and Dictionary types but it keeps failing with this error:

“Unknown object type tag (17)”

The error seems to be returned before the method is even reached suggesting that the cfc is rejecting the Remoting request altogether. I know the code is sound because I can change the structure to a string and get results back. I’ve also tried the Flash.Params method.

I’ve done a fair amount of research already, including studying Adobe livedocs which insists that it’s possible to do.

Here is my code:

loadData_btn.addEventListener(MouseEvent.MOUSE_DOWN, loadData)

var myService = new NetConnection()
myService.connect("http://localhost/flashservices/gateway/") 

function loadData(evt:MouseEvent){
    var responder = new Responder(getTest_Result, onFault);
/* I've tried everything here including defining it as an Object and Dictionary. I also tried
defining it using dot notation and sending it as an object like so: {mystring:"hello"} */
	var mystruct:Array = new Array();
	mystruct["mystring"] = "hello";
	myService.call("com.mycomponent.test", responder, mystruct);
}

function getTest_Result(result){
    trace("success: "+ result);
}

function onFault( f){
	trace("There was a problem: " + f.description);
}

…and here’s my component function (I’ve tried with an argument type of ’struct’ as well as ‘any’):

<cffunction name="test" output="no" access="remote" returntype="string" >
	<cfargument name="argstruct" type="any" required="no" />
	<cfset mystr =arguments.argstruct["mystring"]>
	<cfreturn  mystr />
</cffunction>

Thanks in advance for any help!

rG

SOLUTION: After many hours of Googling, and much trial and error, I figured out how to make this work…and it’s a one line solution. Simply add myService.objectEncoding=0 before the myService.connect line at the top. It has to do with the way objects are serialized using AMF.

as3, coldFusion, remoting

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

10 Responses to “Is it possible to pass a structure to ColdFusion using Flash AS3 / Remoting”

Leave Comment

(required)

(required)