Groups | Blog | Home
all groups > coldfusion flash integration > august 2006 >

coldfusion flash integration : Result not displaying in Flash



Gregory Nelson
8/20/2006 6:25:51 PM
I am trying to get the results of a cfquery to display in Flash. From what I
understand, it should be simple. I have the code below. The results show as
[object, Object]. What am I doing wrong? Please help.

Action Script:

import mx.remoting.NetServices;
import mx.remoting.NetDebug;
mx.remoting.debug.NetDebug.initialize();
import mx.remoting.DataGlue;

//set the default gateway URL
NetServices.setDefaultGatewayUrl("http://66.241.245.41/flashservices/gateway");

var gw = NetServices.createGatewayConnection();
var server = gw.getService("epic.intro", new Result());
server.getintro();

function Result()
{
//receives data returned from the method
this.onResult = function(result)
{
//trace("Data received from server : " + result);
//this is where we put the data in the text field
introView.text = result;
}

this.onStatus = function(error)
{
//trace("Error : " + error.description);
//this is where we put the data in the text field
introView.text = "Error : " + error.description;
}
}


Component:

<cfcomponent displayname="retrieveIntro">

<cffunction name="getintro" access="remote" returntype="query">


<cfquery datasource="epic" name="qgetintro">
Select intro
from intro
</cfquery>

<cfreturn qgetintro>

</cffunction>

</cfcomponent>
The ScareCrow
8/27/2006 11:09:54 PM
The result is a recordset (object) so you can't assign it like that.

Lets assume that the recordset has only one record, then

introView.text = results.getItemAt(0).columnName;

Where columnName is the name of the column in the query result set you want to
assign to the field.

Ken


Gregory Nelson
8/29/2006 3:54:11 PM
Thanks. What if the table has multiple records to return?

The ScareCrow
8/29/2006 11:41:36 PM
In the event the returned recordset has more than one record, it would depend
upon how you are going to display them.

If you use a grid, then
gridName.dataProvider = results;

If using form fields, you can loop through the recordset

if(var x = 0 ; x < results.legth; x++){
do something.............
}

Ken
Gregory Nelson
9/3/2006 11:40:23 PM
Ok. I got it to display the last record in the text field, but I want all of
the records. How would I modify this?

function getconprojects_Result(result){

for(var i = 0 ; i < result.length; i++){
var record = result.getItemAt(i);
_root.Instancename_3.htmlText = ("[B]" + record.project + "[/B]" +"<br>"+
record.location);

}

}
The ScareCrow
9/4/2006 4:14:37 AM
Assuming you want to display them all in the text field, see attached code

Ken

function getconprojects_Result(result){
var textString = "";
for(var i = 0 ; i < result.length; i++){
var record = result.getItemAt(i);
textString = textString + "<strong>" + record.project + "</strong>" +"<br>"+
record.location + "<br>";
}
_root.Instancename_3.htmlText = textString;
}
AddThis Social Bookmark Button