NetServices.createGatewayConnection( )

NetServices.createGatewayConnection( ) MethodFlash 6

connects to the Flash Remoting gateway
NetServices.createGatewayConnection(url)

Arguments

url

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

Returns

A NetConnection object.

Description

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.

Example

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

#include "NetServices.as"

if (connected == null) {
  connected = true;
  theURL = "http://127.0.0.1/flashservices/gateway";
  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 "NetServices.as"

if (connected == null) {
  connected = true;
  NetServices.setDefaultGateway("http://127.0.0.1/flashservices/gateway");
  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
     
    ASPTreeView.com
     
    Evaluation has ЅёґОФЗУЪЗexpired.
    Info...