Flash CS3 AS3 remoting with ColdFusion CFC doesn't work - HELP!

Posted on 2009-03-29
Last Modified: 2013-12-20
I'm attempting to recreate an older Flash Remoting connection to a ColdFusion (8) CFC (which returns a query of pairs of string values) using the new type of "" connection.  It isn't working, so now I've made a function to test that simply should return "...Connection Successful" (see the CFC in the code).  It still doesn't work, and my "OnFault" function fires every time with the resuts of:

[object object]

I need to get this working for my company ASAP.  Please help!  Thanks!

Because I'm in such a hurry, I'm awarding 500 points for the correct (working / workable) answer with proper code.

Here is the ActionScript 3.0 code:
var myservice:NetConnection = new NetConnection();
var responder:Responder = new Responder(onResult, onFault);
function onResult(responder:Object):void {
function onFault(responder:Object):void {
}"cf.myfunctions.testconnection", responder);
Here are the contents of the myfunctions.CFC:
<cfcomponent name="concerts">
<cffunction name="testconnection" access="remote" returntype="string">
<cfreturn "...connection successful">

Open in new window

Question by:vitoasaro
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 19

Expert Comment

ID: 24014921
Take a look at for many examples of Flex and Coldfusion communication.

Author Comment

ID: 24014936
Jones911: Thanks, but I'm not using Flex.  I'm using Flash CS3.  I understand that the Flex communication libraries do a lot more for pulling down SQL data, but I need to make this work with Flash CS3 and AS3.
LVL 19

Expert Comment

ID: 24014945
Oh sorry I miss read.

Accepted Solution

vitoasaro earned 0 total points
ID: 24016371
I've found the answer myself after working on this for the majority of a day...
You must have the correct gateway as shown in my code.  You cannot use:

You must use:
even though BOTH gateways are operative on the ColdFusion server.
Another IMPORTANT issue is if you're testing on your LOCAL PC (as most of us do), but trying to query data from a separate web/SQL server, you need a few more things.  Let's face it: most of us develop on our PCs, but we don't all load the developer version of SQL and run a local web server on our PCs just for the sake of development.  To run on the fly in Flash CS3 without having to compile and upload a .SWF file to the server every time you want to test you'll need to have a CROSSDOMAIN.XML file in the document root of the website you're testing.  For example, if your website is and your document root on your webserver is C:\inetpub\websites\mywebsite then that's the directory where you'll need to put the CROSSDOMAIN.XML file; It will not work for all websites if you put it in the "Default Web Site" (on IIS) directory, so don't bother.  There are three important lines in the XML file:
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" />
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
You can custom tailor these if you can figure out how to make it only allow cross-domain communication to the domains you prefer by changing the asterisks (*) to actual domains.  Since I was testing from a "non-domain" PC, it was best to leave it able to allow data to be sent everywhere (the *).   In my ActionScript 3.0 code I also added:
but this was for good measure after the above XML file made communications work.   On a side note, I read that PHP uses AMF0 to serialize it's data, but for Flash AS3 with CFC you need to use AMF3 (as you can see in my code).
Furthermore, it was a HUGE mystery for how to actually PARSE the data returned from a Coldfusion CFC query because everything I found via Google only showed examples of displaying a single string result returned from the CFC (as shown in my earlier code).  HOWEVER,  it is quite different when you need to retrieve all columns of data from a SQL query for all the rows (resultset) returned.  You need to use the very important
appended to whatever your variable object is named (the variable in between the parens of the OnResult function).  ADDITIONALLY, the data is referenced by elements within brackets.  The number in the first set of brackets refers to the ROW # of the data, and the number in the second set of brackets refers to the COLUMN NUMBER (not the name) of the data, starting with column 0, not 1, as your first column returned from a SQL query.
I took the time to collect all the data I've spent yesterday and today trying to piece together information in three different languages so that it could be found in one place for the next poor soul who is attempting to use Flash CS3 with ActionScript 3.0 to communicate with a Coldfusion CFC and retrieve SQL data.  Adobe has NO DOCUMENTATION available anywhere on their site for this, and that's just plain wrong.  For all the money I've invested in their products (thousands of dollars) I'd expect to receive some documentation PDFs that cover this information.  At LEAST they need to make it available on their website!!
Good Luck

import flash.text.*;
import flash.utils.setTimeout;
var myservice:NetConnection = new NetConnection();
myservice.objectEncoding = ObjectEncoding.AMF3;
var responder:Responder = new Responder(onResult, onFault);  //This is triggered by a good or bad connection
function onResult(re: Object):void {  // Call this function when good data is retrieved
	var allRows:Number =re.serverInfo.totalCount;  //This sets a variable (allRows) to the total number of 							  rows returned by the query
	for(var i=0; i<allRows; i++ )  // This loops through each row of the returned recordset (query)
// The serverinfo.initialData is the key to retrieving your SQL data!!!
// The first []'s refer to the SQL ROW # of data returned
// The second []'s refer to the SQL COLUMN of data returned (starting with 0 for the first column)
// There is no data-provider feature toreference your data by column NAME, only by column NUMBER
	trace("QUERY RESULT, ROW="+i+", Column=1('performanceName'): "+re.serverInfo.initialData[i][0]);
	trace("QUERY RESULT, ROW="+i+", Column=2('ImageName'): "+re.serverInfo.initialData[i][1]);
function onFault(re:Object):void {
	var i:Object;
	for(i in re ){
	trace("Error. Didn't connect or didn't retrieve data.");
// This last line actually calls the method (the FUNCTION) in the CFC.
// Notice how this is different from AS2 because in AS3 the last thing in the quotes is the
// FUNCTION name itself.  I.e., this tells Flash to look in the cf directory for the cffunctions(.cfc) file
// and use the imagelist function in that CFC."cf.cffunctions.imagelist", responder);
<cfcomponent name="concerts">
<cffunction name="imagelist" access="remote" returntype="query">		
<cfquery name="ImageList" datasource="concerts">
select performanceName, performanceImage
from ConcertsData
WHERE ((performanceImage<> '')
<cfreturn ImageList>
<?xml version="1.0"?> 
<!DOCTYPE cross-domain-policy SYSTEM ""> 
<site-control permitted-cross-domain-policies="all"/> 
<allow-access-from domain="*" /> 
<allow-http-request-headers-from domain="*" headers="*" secure="false"/> 

Open in new window


Author Comment

ID: 24016380
The information was EXTREMELY difficult to come by, was found in only a few obscure sites on the web, and in three different languages.  I've answered it in detail here for the next unfortunate person who has trouble.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to generate a csr to request an intermediate ca on os x 3 68
wordpress limitations 4 136
site launch date and last modified date 3 105
Link failure 16 69
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question