Setting up Flash Remoting with ColdFusion

I would like very much to thank Eric Meyer from curious minds

for helping me figure this out`-` I had started to try to convert a actionscript 2 remoting app to actionscript 3, but got really confused towards the end. I saw a post on his blog, and he was nice enough to work with me over e-mail fixing all my confusion!

Check out his blog, lots of great information.

Setting up flash remoting with actionscript 3.0 and flash CS 3.
Create a fla, call it remoting(or something that makes sense to you).

In the actions, type the following code


import flash.net.*;
var gateway:NetConnection = new NetConnection();

var responder:Responder=new Responder(onResult,onFault);





function onResult(responds:Object):void {

	trace("cfc result"+":"+" "+responds.toString());

}



function onFault(responds:Object):void {

	//loop over the fault structure

	for (var i:String in responds) {

		trace( i + ":" + responds[i] );



	}

}



// name the default cf test server on this machine

gateway.connect("http://localhost/flashservices/gateway/");



// name of the cfc and the function in it that you want to hit in dot notation

gateway.call("com.cfcs.getTest.getTestConn", responder/*this is where any arguments to the remote call go*/);



The cfc lives on my localhost/com/cfcs/gettestConn.cfc

The cfc will look like this


<cfcomponent displayName="getTest">

  <!--- Establish a Flash Remoting Connection --->

  <cffunction name="getTestConn" access="remote" returnType="string" output="true">

    <cfreturn "....connection successful">

   </cffunction>

 </cfcomponent>

This is just the set up, and yep just returns the string from the cfc. Once set up, you can use remoting the way that it is meant to be used`-`

Any question, problems? Let me know I will try to help.

I will posting another example on how to display the results from your cfc, and later how to pull database results into your flash movie as well.

happy coding`-`

2 thoughts on “Setting up Flash Remoting with ColdFusion”

  1. thanks john, it works, the function name is “getTestConn” and not “getTest”.

    i tried [gateway.call(“com.cfcs.getTestConn.getTestConn”, responder/*this is where any arguments to the remote call go*/);] it works.

    thank you 4 ur help.

Leave a Reply