I have a problem that I need a general solution for. I have in the past used
the timeline to allow for the delays in getting remote data, by putting the
functions that use the data a few frames down the line, so the data has arrived
by the time the frame is reached. I use Response Object functions to collect
and allocate the data to various arrays, which I then use later. However, when
I am using classes to construct the program, I don't have that option so
easily. The program runs the response function, then immediately moves to the
next program line before the data is returned. How can I force it to wait for
the results? Shouldn't the response object hold the program till it's finished?
Is there a method that does that, like OnData? Here's an example. I have a
command leading to the remote data, followed by a trace command to see the
result. remoteUserSettingsCall(userName, password); trace('remote userID
'+thisUserIDObject.userID); trace(testme); Then I have a response object to
collect the data. responseObjLogin = new Object();
responseObjLogin.onResult=function (result) { trace('USERIDresponseObjLogin
'+result.USERID); thisUserIDObject.userID=result.USERID; testme='hello';
}//end response The output shows the results of the last trace commands
first: remote userID undefined abc USERIDresponseObjLogin 03902 I realise I
have some naming issues with the variables, but that may be a future question!
I am mainly concerned now with being able to put the commands in order
correctly. Any ideas?
DulcieJ - 27 Jan 2005 15:49 GMT
Still new to this stuff, but I think you need to put any code that deals with
the result of a remote call in a result function. You code needs to be
non-linear once you make the first remote call because there is no sure way to
determine how long it may take to get the result. I group my code in functions
that call each other in a linear way but each function has a final line with a
remote service call and the next function called is triggered when the result
is returned. HTH D.
allan_h - 27 Jan 2005 23:19 GMT
Thanks for your reply. Yes, I think you're right, chaining the connections to the next event is the solution.