Name
NetServices.setDefaultGateway( ) Method
Synopsis
NetServices.setDefaultGateway(url
)
Arguments
-
url
A string containing the URL of a Flash Remoting gateway adapter.
Description
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.
Example
The following code shows the basic syntax of the setDefaultGateway( ) method:
#include "NetServices.as" if (connected == null) { connected = true; NetServices.setDefaultGateway("http://127.0.0.1/flashservices/gateway"); 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="http://download.macromedia.com/pub/shockwave/cabs/flash/ swflash.cab#version=6,0,0,0" WIDTH="550" HEIGHT="400" id="mymovie" ALIGN=""> <PARAM NAME=movie VALUE="mymovie.swf"> <PARAM NAME=FlashVars VALUE="gatewayURL=http://www.flash-remoting.com/flashservices/gateway"> ...
Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.