PDA

View Full Version : Possible to pass a structure from AS3 to CF8?


rabidGadfly
05-19-2008, 08:46 PM
I'm trying to pass a structure to a ColdFusion component from Flash but it keeps failing with this error:

"Unknown object type tag (17)"

Here's my AS. I've tried using Array, Object, and Dictionary as types:

loadData_btn.addEventListener(MouseEvent.MOUSE_DOW N, loadData)

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

function loadData(evt:MouseEvent){
var responder = new Responder(getTest_Result, onFault);
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="yes" />
<cfset mystr =arguments.argstruct["mystring"]>
<cfreturn mystr />
</cffunction>


I was successful in sending and returning a string as a test to ensure that the apps were set up correctly. It's only when I try to pass a struct that I get an error.

Thanks in advance for any help,
Glenn

rabidGadfly
05-20-2008, 08:07 PM
Found my own 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 of the AS code. It controls the way objects are serialized using AMF.

See my post for more information:
http://www.rabidgadfly.com/?p=65