This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Remoting Basics
If a remote server fails to process a call, it returns an error object and invokes a sta-
tus method (in this case, “status” is a euphemism for “error”). Regardless of how you
handle the error message, which depends on how you defined your response object,
Flash Remoting always passes a single error object to the status method. The error
object returned by the remote server includes
level and description properties speci-
fying the error severity and an explanation of why the server couldn’t perform the
request. The values of these properties, while not always completely accurate, are
invaluable in debugging the error.
If you use the methodname_Result( ) approach for your responder, you should spec-
ify a methodname_Status( ) function to catch any errors. There are still yet other
options, however. The NetServices package dispatches the onStatus error from a
remote call in the following order, stopping when it finds an appropriate handler:
1. First, it looks for a function named methodname_Status( ) defined on the
response object or the current timeline.
2. Otherwise, if a response object with an onStatus( ) method was specified in the
call to getService( ), status errors are sent to that onStatus( ) method. (If you pass
a response object with an onResult( ) method as the first parameter to the remote
method call, an onStatus( ) method is called only if it is attached directly to the
response object. If you pass such a response object to each remote method call,
the handlers cited in Steps 3 and 4 are never called.)
3. Otherwise, the _root.onStatus( ) method, if any, is used.
4. Otherwise, the _global.System.onStatus( ) method, if any, is used.
5. Otherwise, if the movie is playing in the authoring environment, results are sent
to the Output window.
6. Otherwise, the results are lost.
In many situations, there is not any meaningful action that the client can take to cor-
rect the problem at runtime. Depending on the application, you may simply report
the error to the user, stating that the remote service is unavailable. In other cases, the
error can be corrected by adjusting the parameters that are sent to the remote server.
At other times, intermittent connection errors, such as with HTTP calls, can be
solved by simply trying again. When an HTTP call fails in Breeze Live, the applica-
tion typically retries it five times at 1-second intervals. (You should avoid being so
aggressive in retrying as to create an inadvertent denial-of-service attack.)
Passing Datatypes
All the basic ActionScript datatypes can be passed through AMF with remoting. A
remote server can interact with the passed datatype using its native syntax. The
actual translation of datatypes varies by remoting implementation; consult Flash
Remoting: The Definitive Guide or your remoting gateway documentation to see how
each datatype is deserialized on the server. Passing most ActionScript datatypes

Get Programming Flash Communication Server now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.