You want to handle the results from calling a service function using Flash Remoting.
Use a named result function or, as a better alternative, use a response object.
Unlike invocations of functions and methods that are defined within
the Flash movie, Flash Remoting service function invocations are
asynchronous. This means that when the ActionScript interpreter
encounters a remote service function call within the code, it
initiates the call but does not wait for a response before continuing
to the next line of ActionScript code. The same thing is true when
loading any external content, be it by means of an
XML object, a
object, or a movie clip using
loadMovie( ). This
asynchronous behavior allows the Flash movie to continue to run
without waiting on something that has the potential for high latency.
Therefore, if a remote service function returns a value, you cannot
use that value within your ActionScript code immediately, as you
would the return value of a native ActionScript function or method.
myVariableis undefined because the service function // does not return a value immediately. myVariable = myService.myServiceFunction(responseObject);
Instead, you have to use a response object with callback functions or methods to obtain the result. There are two ways to handle results from a Flash Remoting service function, and they correspond to the two variations of invoking the service function (see Recipe 20.6 ...