PDA

View Full Version : Copying a Recordset to a variable


adi_ady_ade
04-24-2003, 06:18 PM
I'm having trouble copying a RecordSet to a local variable so I can use it outside of the result function.

Here's the code I've tried, I've gone through lots of combinations but still can't get it right. I want to assign the Recordset returned to the local variable myResult and use it elsewhere in the ActionScript.



NetServices.setDefaultGatewayUrl... etc
var gw = NetServices... etc
var server = gw.getService( "cfcs.navigation", new Result() );
server.getMainNavigation();

var myResult;

function Result() {

this.onResult = function(result) {

if ( result.isFullyPopulated() ) {
trace("1: " + result.getItemAt(0)["DefaultURL"]); // This works
myResult = result;
trace("2: " + myResult.getItemAt(0)["DefaultURL"]); // This works
}

//trace("Data received from server : " + result);
//trace(result.getItemAt(0)["URL"]);
}

this.onStatus = function(error)
{
trace("Error : " + error.description);
}
}


trace("3: " + myResult.getItemAt(0)["DefaultURL"]); // This doesn't work



Can anyone point me in the right direction?

Thanks

freddycodes
04-24-2003, 07:53 PM
Is that exactly how it looks in your movie, all in the same frame. If so, thats the problem, because the resultset isn't populated until the function is run, and you try to call it before it has loaded. Flash plays the entire frame from top to bottom, and the function never finishes before the trace line is called below the function.

adi_ady_ade
04-25-2003, 09:43 PM
I'd read something like that.

So what's the solution to it, I would of thought that having all the code in the same frame would be ok?

Should I put the call to the server in the first frame and all the manipulation in another frame? It doesn't seem quite right somehow :confused:

Can anyone point me towards good tutorials, all the ones I've found seem to do the same things?

Thanks for the reply.

Ade

freddycodes
04-26-2003, 12:49 AM
Well just move to the second frame after the result function runs and try tracing it there. Like this


//Frame 1:
NetServices.setDefaultGatewayUrl... etc
var gw = NetServices... etc
var server = gw.getService( "cfcs.navigation", new Result() );
server.getMainNavigation();

var myResult;

function Result() {

this.onResult = function(result) {

if ( result.isFullyPopulated() ) {
trace("1: " + result.getItemAt(0)["DefaultURL"]); // This works
myResult = result;
trace("2: " + myResult.getItemAt(0)["DefaultURL"]); // This works
}

//trace("Data received from server : " + result);
//trace(result.getItemAt(0)["URL"]);
play();
}

this.onStatus = function(error)
{
trace("Error : " + error.description);
}
}
stop();


//Frame 2:

trace("3: " + myResult.getItemAt(0)["DefaultURL"]); // This doesn't work
stop();