FMX2004 Remoting with CFMX2004

Hey everybody,

I’m sorry if this question seems more about ColdFusion than Flash, but it is in the Flash application that I am encountering the problem.

I am having a heck of a time trying to get Flash and Cold Fusion to cooperate. Either I am crazy, or it seems like all the documentation is just plain incorrect. I have created a ColdFusion component which returns information about home lots from the database in an array of structs. The component works fine when accessed by another CFM page, but Flash just refuses to believe that the variable I am returning is an array. Regardless of what I do, it seems to treat everything I send back as an Object, despite the fact that I explicitly tell it that the result will be an array.

I have found that if I send back a simple array, of say, integers, I can access them as an array even though Flash will claim I am sending an Object. However, this only works for accessing data directly (i.e. lotArray[0])… I don’t think any of the methods are working. When I send back an array of structures, Flash will not display any information for the structures inside.

Has anyone else come across this problem? I’m really pulling out my hair here. All the documentation I’ve read tells me to do exactly what I am doing, and yet Flash does not cooperate. If anyone has any idea how to get this going, please let me know. As a last resort, I know I could rework my data so it comes back in some kind of form that Flash can understand, but it will be awkward, and make the component useless for use with CFM-only apps, which is kind of the point of using a component in the first place.

Here is my connection code:

import mx.remoting.Service;
import mx.services.Log;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.PendingCall;
import mx.remoting.RecordSet;

// connect to service and create service object
var DTHService:Service = new Service(
http://www.abcdefg.com/flashservices/gateway”,
new Log(),
“webservices.Lot”,
null,
null );

// call the service getLotArray() method
var pc:PendingCall = DTHService.getLotArray();

// tell the service what methods handle result and fault conditions
pc.responder = new RelayResponder( this, “getLotArray_Result”, “getLotArray_Fault” );

function getLotArray_Result(result:ResultEvent)
{
// display successful result
var lotArray:Array = new Array();
lotArray = result.result;
trace("lot: " + lotArray[0].id);
trace("price: " + lotArray[0].price);
trace("length: " + lotArray.length);
price_txt.text = lotArray[0].price;
id_txt.text = lotArray[0].id;
}

function getLotArray_Fault(fault:FaultEvent)
{
//display fault returned from service
price_txt.text = “unsuccessful”;
error_txt.text = fault.fault.faultstring;
}


Here is the function tag from CFM:
<CFFUNCTION name=“getLotArray” access=“remote” returntype=“array”>

There are no parameters required. The actual function itself is pretty long and complicated, and doesn’t seem necessary to post since i know it works when I test it through CFM. If anyone thinks it necessary, however, I can post the CFM code as well.

Thank you all in advance!

Just a hint, it may help…

instead of


trace("lot: " + lotArray[0].id);
trace("price: " + lotArray[0].price);

try


trace("lot: " + lotArray[0].ID);
trace("price: " + lotArray[0].PRICE);

yes, UPPERCASE variables. try it

Thanks very much for your help. It did work when I switched to capitals although I have no idea way. Then, later on, the caps stopped working and I had to switch back to lower/mixed case. Weird…

Then, later on, the caps stopped working and I had to switch back to lower/mixed case. Weird

indeed, weird…:puzzle:

it seems that coldfusion is always storing the variables upper-case. you can see it when you perform a <[font=Courier New][color=darkred]cfdump …/>[/color][/font] with any struct or query you created…