Name
NetConnection.connect( ) Method
Synopsis
myNetConnectionObject
.connect(targetURL
)
Arguments
-
targetURL
A URL of the Flash Remoting gateway that you wish to connect to. The URL can be prepended with an http:// or https:// protocol, but can also be used without any protocol, which defaults to http://.
Returns
true
if the protocol is valid
(http:// or https://), and
false
otherwise.
Description
The connect( ) method is used to connect to a Flash Remoting gateway. Using the connect( ) method does not require the inclusion of the NetServices.as file. The word connect is something of a misnomer; at no time during this call does the NetConnection object connect to the remote server. The actual connection takes place when a service function call is made.
Example
The following code shows the basic syntax of the connect( ) method:
// Create the connection var my_conn = new NetConnection( ); // Attach a URL for the gateway my_conn.connect("http://127.0.0.1/flashservices/gateway");
In most cases, you will not use this method directly but instead use the createGatewayConnection( ) method, which instantiates a NetConnection object and connects to it as well.
See Also
NetConnection.ReplaceGatewayUrl( ), NetServices.createGatewayConnection( ), NetServices.setDefaultGateway( ); Chapter 4
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.