Debugging and Monitoring Applications > Using onStatus event handlers

 

Using onStatus event handlers

The client-side Camera, Microphone, NetConnection, NetStream, and SharedObject objects, as well as the server-side Application, NetConnection, Stream, and SharedObject objects, provide an onStatus event handler that uses an information object for providing information, status, or error messages. To respond to this event handler, you must create a function to process the information object, and you must know the format and contents of the information object returned.

By default, every information object has a code property containing a string that describes the result of the onStatus method, and a level property containing a string that is either "status", "warning", or "error". Some information objects have additional default properties, which provide more information about the reason onStatus was invoked.

For more information about the values returned by various onStatus handlers, see the Client-Side Communication ActionScript Dictionary. The following table summarizes the information objects returned by certain server-side calls; 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 Communication ActionScript Dictionary.)

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


The next sections include additional recommendations on how to write applications to best implement this feature.