NetServices.setDefaultGateway( )

NetServices.setDefaultGateway( ) MethodFlash 6

sets a default URL for a gateway connection



A string containing the URL of a Flash Remoting gateway adapter.


The setDefaultGateway( ) method is a way that you can define a URL for your NetConnection object but allow it to be overridden by a URL passed from the HTML page that houses your Flash movie. In this way, a URL can be set up in the movie for testing or deployment, but if the URL has to change at any time in the future, the URL can be passed to the Flash movie using the gatewayURL variable.

After setting up the default URL using this method, the createGatewayConnection( ) method can be called with no arguments to create a NetConnection object.


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

#include ""

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

To override the default gateway URL, the gatewayURL variable can be passed to the movie using the FlashVars attribute in the HTML page that embeds the .swf file:

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase=",0,0,0" WIDTH="550" HEIGHT="400"
 id="mymovie" ALIGN="">
 <PARAM NAME=movie VALUE="mymovie.swf">
 <PARAM NAME=FlashVars
 <PARAM NAME=quality VALUE=high>
 <EMBED src="mymovie.swf" quality=high bgcolor=#FFFFFF  WIDTH="550"
  HEIGHT="400" NAME="Untitled-2" ALIGN=""

In this example, the FlashVars attribute contains the name/value pair of gatewayURL and the path to the Flash Remoting gateway on my server. You should update it for your server:


The gatewayURL is a variable that the NetConnection object is expecting. It overrides any gateway URL set via setDefaultGateway( ) but does not override a URL set via createGatewayConnection( ). Therefore, you should not pass a URL to createGatewayConnection( ) when using the FlashVars approach.

See Also

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

    Part III: Advanced Flash Remoting