68
Client-Side ActionScript Language Reference
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 class” on page 79
).
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_ns.close();
// deletes the source stream connection
my_nc.close();
}
See also
NetConnection.connect()
,
NetConnection.onStatus
,
NetStream.close()
,
SharedObject.connect()
NetConnection.connect()
Availability
■
Flash Player 6.
■
Flash Communication Server MX 1.0.
Usage
public connect(
targetURI
:String) : Boolean