
Server-Side Communication ActionScript 47
NetConnection.isConnected
Availability
Flash Communication Server MX.
Usage
myNetConnection.isConnected
Description
Property (read-only); a Boolean value that indicates whether a connection has been made. It is set
to
true if there is a connection to the server. It’s a good idea to check this property value in the
onStatus callback function. This property is always true for AMF connections to application
servers.
Example
This example uses NetConnection.isConnected inside an onStatus definition to check if a
connection has been made:
nc = new NetConnection();
nc.connect("rtmp://tc.foo.com/myApp");
nc.onStatus = function(infoObj){
if (info.code == "NetConnection.Connect.Success" && nc.isConnected){
trace("We are connected");
}
};
NetConnection.onStatus
Availability
Flash Communication Server MX.
Usage
myNetConnection.onStatus = function(infoObject) {
// Your code here
};
Parameters
infoObject An information object. For details about this parameter, see Appendix, “Server-
Side Information Objects,” on page 77.
Returns
Nothing.
Description
Event handler; invoked every time the status of the NetConnection object changes. For example,
if the connection with the server is lost in an RTMP connection, the
NetConnection.isConnected property is set to false, and NetConnection.onStatus is
invoked with a status message of
NetConnection.Connect.closed. For AMF connections,
NetConnection.onStatus is used only to indicate a failed connection. Use this event handler to
check for connectivity.
Commentaires sur ces manuels