Remoting through Flex with Coldfusion

I’m used to setting the ObjectEncoding to AMF0 when working with Flash Media Server 2, but haven’t realized till now that I also am required to do this when communicating with Coldfusion 8 through remoting:

import flash.net.NetConnection;
import flash.net.ObjectEncoding;
NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;

The error “Unknown object type tag (17)” was being generated by CF8 as I attempted to pass an Object in AS3 over remoting to CF8 interpreted as a Structure. Apparently, there is also the need to wrap any such Object within a container Object for it to be properly read by the CFC:

var wrapper:Object = new Object();
wrapper.submissionObject = submissionObject;
submissionResponder = new Responder(onSubmissionResult, onSubmissionError);
testConnection.call("some.cfc.Test", submissionResponder, wrapper);

The CFC function expects a Structure named “submissionObject” in this case.

I hope this is helpful for someone- I had a hell of a time digging up this information.

6 thoughts on “Remoting through Flex with Coldfusion”

  1. You don’t need to use AMF0 with CF8. You should stick with AMF3 and if your problem is to have a struct in cf side when only having 1 argument in your remote function, try to add a dummy null argument in your AS function call someFunction.call( submissionObject , null )

  2. Hey João. I’m not entirely sure your meaning from the example you’ve given. I’ve tried a number of things and still am returned “Unknown object type tag (17)” when switching to AMF3.

    Believe me, I’d love to use AMF3, but I also need this to function correctly.

  3. Hi,

    I have a problem, what I have done is built a large flex app which now needs to be AIR. I have configured my AMF0RemoteObjects to point to the server where all my CFC’s and datasource reside. When I am returning my array of objects from the server to the app i am just getting an array wheere each position contains the methods from whichever CFC I am using.

    E.G.

    I have a User.as and a User.cfc

    the User.as has properties userName:String and password:String

    User.cfc has setUserName getUserName setPassword getPassword init load save delete etc.

    If I run the app as a Flex web app it works fine – my CF objects get converted into AS objects as well as my AS objects becoming CF. Is this happening because of the encoding and is there a way I can fix this?

  4. ***** When I am returning my array of objects from the server to the app i am just getting an array wheere each position contains the methods from whichever CFC I am using. *****

    Should read

    When I am returning my array of objects from the server to the app i am just getting an array where each position contains the methods from whichever CFC I am using rather than the actual values.

  5. Hey Sam. There isn’t nearly enough information provided for me to be able to assist you. If there is something more specific, then please let me know and I will be happy to have a peek as I find the time.

  6. I love the web! You get an error message, you throw it in Google, and here’s the answer! VERY helpful my friend. There is very little info out there about AS3 flash remoting, especially with Coldfusion. Seems more popular with the PHP guys. By the way, just for fun I threw in ‘AMF3’ instead of ‘AMF0’ and guess what? It still didn’t work, as you mentioned previously. But you also mentioned you wish you could use AMF3, so I was wondering what we’re missing using AMF0. Care to shed some light?

Leave a Comment

Your email address will not be published. Required fields are marked *