Client-Side Information Objects > Client-side information objects overview

 

Client-side information objects overview

The Camera, Microphone, LocalConnection, NetConnection, NetStream, 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.

In addition to the specific onStatus methods provided for the objects listed above, Macromedia Flash also provides a "super" function called System.onStatus. If onStatus is invoked for a particular object with a level property of "error" and there is no function assigned to respond to it, Flash processes a function assigned to System.onStatus if it exists.

The following example illustrates how you can create generic and specific functions to process information objects sent by the onStatus method.

// Create generic function
System.onStatus = function(genericError)
{
	// Your script would do something more meaningful here
	trace("An error has occurred. Please try again.");
};

// Create connection functions
// If the connection attempt returns a different information object
// from those listed below, with a level property of "error",
// System.onStatus will be invoked

nConn.onStatus = function(infoObject)
{
	if (infoObject.code == "NetConnection.Connect.Success")
	{
		trace("Successful connection.");
	}
	if (infoObject.code == "NetConnection.Connect.Failed")
	{
		trace("Connection failed.");
	}
};

//	 Attempt to open connection
nConn = new NetConnection();
nConn.connect("rtmp://myServer.myDomain.com/myRTMPapp");

The following tables show the default properties of each information object and the circumstances under which onStatus is invoked with each information object. When referring to the tables, note the following:

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. These properties are noted as footnotes in the tables.

For NetStream, NetConnection, and remote shared objects, which are available only with Macromedia Flash Communication Server MX 1.5, the properties of the information objects are determined by the methods available in server applications and should be documented by the developers of your server-side application. The properties listed here are the ones available by default; that is, these are the properties available if your server-side application doesn't specify other information object properties. For information on using Flash with an application server, see Using Flash Remoting.

For objects that do not require Flash Communication Server (Camera, Microphone, LocalConnection, and local shared objects), the properties listed here are the only ones available to onStatus, and no server-side application is required.