all groups > macromedia flash flash remoting > april 2004 >
You're in the

macromedia flash flash remoting

group:

How do i wait for remoting results.


How do i wait for remoting results. mikeDrex
4/29/2004 7:01:30 PM
macromedia flash flash remoting:
I would like to dynamically add instances of a class to another one that was
also created from a database . The problem i have is that the result passes
back a string in a global var. I need to then pass that to a CFC in order to
get the data to create the new objects. However, since flash doent wait for
the results to finish loading before it continues the data passed to the second
remoting call gets an undefined value.

How would i stop processing until i have the results back. If i put the
second call on a later timeline it works or if i check on frame 3 to if the
results are undefined and loop back to 2 until it is done then i can run it on
frame 4. This seems to work in initial testing but i know there has to be a
better way using a listener or something so i do not have to depend on putting
it on different frames and checking for all results.







Re: How do i wait for remoting results. wadearnold
4/30/2004 5:50:17 AM
It is possible to define a new resut object for the first query. In the new
result object get the data returned from the server and call another service
with its own result object. It seems to work well for me.


var qry1Result = new Object();
var qry2Result = new Object();

qry1Result.onResult = function(result) {
if (result.getItemAt(0).something = "somethingThatYouWant") {
service.qry2(qry2Result, result.getItemAt(0).something);
} else {
// do something else
}
}

qry2Result.onResult = function(result) {
// do second thing
}

service.qry1(qry1Result, variable);

wade // hope i understood your question


Re: How do i wait for remoting results. Hunt?r
4/30/2004 11:47:21 PM
I would concur with Wade , although I code it slightly differently which I'm
sure doesn't matter, but here is my equiv...

First Call:

function callOne(){
// Do whatever server calls here you wish
getData.callOneToCfc(); // This for instance calls to the cfc a
function called "callOneToCfc"
}

Now let's say you want to wait until the results come back before making the
next call which needs the data from the first, and needs to take that data and
send it to the server for the next result... You create a result function like
this:
Note: This function will not commence until the result set is processed and
returned from the server

function callOneToCfc_Result(result){
getData.nextCallToCfc({varToSend: result});
}

Then ....

function nextCallToCfc_Result(result){
getData.callAfterThatToCfc({varToSend: result});
}
And so on.....
Of course you could do this all iun a loop which I believe would handle your
dynamics you were speaking of...

-- H?nter




AddThis Social Bookmark Button