NetServices.createGatewayConnection( )

NetServices.createGatewayConnection( ) MethodFlash 6

connects to the Flash Remoting gateway



An optional string containing the URL of a Flash Remoting connection.


A NetConnection object.


The createGatewayConnection( ) method is the best way to create a new NetConnection object. You can set up a default URL in the ActionScript code and then override it with a URL passed from the HTML page that houses the Flash movie. The newly created NetConnection object is used connect to the Flash Remoting adapter on the server. You also call remote methods through the NetConnection object. The NetConnection object also handles the service results.


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

#include ""

if (connected == null) {
  connected = true;
  theURL = "";
  var my_conn = NetServices.createGatewayConnection(theURL);

In this code, the gateway URL is passed to the createGatewayConnection( ) method. If the URL is passed in this way, it overrides any other URLs that have been set up.

Here is a more flexible way to create a connection:

#include ""

if (connected == null) {
  connected = true;
  var my_conn = NetServices.createGatewayConnection( );

In this case, the URL is passed to the setDefaultGateway( ) method, which gives you more flexibility because the default gateway URL can be overridden by passing a URL from the HTML page. See the entry for NetServices.setDefaultGateway( ) for more information.

See Also

The NetConnection class, NetServices.setDefaultGateway( ); Chapter 4

    Part III: Advanced Flash Remoting