Server-Side Communication ActionScript > NetConnection.connect |
![]() ![]() ![]() |
NetConnection.connect
Availability
Flash Communication Server MX.
Usage
myNetConnection.connect(URI
, [p1, ..., pN
])
Parameters
URI
A URI to connect to.
p1, ..., pN
Optional parameters that can be of any ActionScript type, including references to other ActionScript objects. These parameters are sent as connection parameters to the application.onConnect
event handler for RTMP connections. For AMF connections to application servers, any RTMP parameters are ignored.
Returns
For RTMP connections, a Boolean value of true
for success; false
otherwise. For AMF connections to application servers, true
is always returned.
Description
Method; connects to the host. The host URI has the following format:
[protocol://]host[:port]/appName[/instanceName]
For example, the following are legal URIs:
http://appServer.mydomain.com/webApp rtmp://rtserver.mydomain.com/realtimeApp
It is good practice to write an application.onStatus
callback function and check the NetConnection.isConnected
property for RTMP connections to see whether a successful connection was made. For Action Message Format connections, check NetConnection.onStatus
.
Example
This example creates an RTMP connection to another Flash Communication Server for the myConn
instance of NetConnection:
myConn = new NetConnection(); myConn.connect("rtmp://tc.foo.com/myApp/myConn");
The following example creates an AMF connection to an application server for the myConn
instance of NetConnection:
myConn = new NetConnection(); myConn.connect("http://www.xyz.com/myApp/");
![]() ![]() ![]() |