Client-Side Communication ActionScript > NetConnection.close |
![]() ![]() ![]() |
NetConnection.close
Availability
![]() |
Flash Player 6. |
![]() |
Flash Communication Server MX. |
Usage
myConnection
.close()
Parameters
None.
Returns
Nothing.
Description
Method; closes the connection with the server and invokes NetConnection.onStatus
with a code
property of NetConnection.Connect.Close
. For more information, see NetConnection.onStatus
.
This method disconnects all NetStream objects running over this connection; any queued data that has not been sent is discarded. (To terminate server streams without closing the connection, use NetStream.close
.) If you want to reconnect, you must recreate the NetStream object (see Constructor for the NetStream object).
This method also disconnects all remote shared objects running over this connection. However, you don't need to recreate the shared object to reconnect. Instead, you can just call SharedObject.connect
to reestablish the connection to the shared object. Also, any data in the shared object that was queued when you issued NetConnection.close
will be sent after you reestablish a connection to the shared object.
Example
The following disconnect()
function stops the published stream, then calls NetConnection.close
to delete the source connection. With no source stream to play, the destination stream automatically ends and is deleted.
function disconnect() { // Stops publishing the stream. srcStream.close(); // Deletes the source stream connection. connection.close(); }
See also
NetConnection.connect
, NetConnection.onStatus
, NetStream.close
, SharedObject.connect
![]() ![]() ![]() |