NetConnection.close( )

NetConnection.close( ) MethodFlash 6

closes a connection to the Flash Remoting server
myNetConnectionObject.close( )

Description

The close( ) method is used to close a connection to the Flash Remoting server. A connection is not a physical connection to the server, so this method does not physically close anything. It merely sets the URL of the NetConnection object to null, thereby causing any further attempts to connect to the server to fail.

Example

The following code shows the basic syntax of the close( ) method:

if (connected == null) {
  connected = true;
  NetServices.setDefaultGatewayUrl("http://127.0.0.1/flashservices/gateway");
  var my_conn = NetServices.createGatewayConnection( );
  var verified = myLoginService( );
  if (!verified) my_conn.close( );
}

In this case, another method named myLoginService( ) is called. If the result of that service call is false, the connection to my_conn is closed at the ActionScript level, thereby nullifying any further attempts to connect to services using the my_conn connection. In practice, the close( ) method is not used very often, as connections need not be closed in most situations.

See Also

NetConnection.connect( ); Chapter 4



    Part III: Advanced Flash Remoting