About onStatus event handlers
77
For more information about the values that various
onStatus
handlers return, see the
Client-
Side ActionScript Language Reference for Flash Media Server 2
. The following table summarizes
the information objects that certain server-side calls return; the server-side call on the left
invokes the client-side
NetConnection.onStatus
handler with the code value on the right.
(This information is not included in the
Client-Side ActionScript Language Reference for Flash
Media Server 2
.)
The following sections include additional recommendations on how to write applications to
best implement this feature.
Where to use onStatus handlers in a script
Because of network and thread timing issues, it is best to place an
onStatus
handler before a
connect
method in a script. Otherwise, the connection might complete before the script
executes the
onStatus
handler initialization. Also, all security checks are made within the
connect
method, and notifications are lost if the
onStatus
handler is not yet set up.
About overriding the onStatus handler
Even if you don’t need to do anything in the
onStatus
handler, it’s a good idea to override the
generic
onStatus
handler whenever you create an object, as shown in the following example:
// Create function to trace all the status info.
function traceStatus(info) {
trace("Level: " + info.level + " Code: " + info.code);
}
// Assign this function to onStatus handlers when you create objects.
var my_nc:NetConnection = new NetConnection();
my_nc.onStatus = traceStatus;
var my_ns:NetStream = new NetStream(my_nc);
my_ns.onStatus = traceStatus;
As you develop your application and determine that you need to actually override the handler
for a specific purpose, you can modify the code that assigns the
traceStatus()
function to
your
onStatus
handler, but in the meantime you can at least see all of the messages related to
your application.
Always check for status messages on both the client and server.
Server-side call
Code value for client-side
NetConnection.onStatus handler
application.acceptConnection()
NetConnection.Connect.Success
application.rejectConnection()
NetConnection.Connect.Rejected
application.disconnect()
NetConnection.Connect.Closed
Содержание FLASH MEDIA SERVER 2-DEVELOPING MEDIA
Страница 1: ...Developing Media Applications ...
Страница 6: ...6 ...
Страница 10: ...10 About This Manual ...
Страница 36: ...36 Flash Media Server Architecture ...
Страница 80: ...80 Debugging and Monitoring Applications ...
Страница 106: ...106 Application Development Tips and Tricks ...
Страница 114: ...114 ...