NetConnection Object


The NetConnection object maintains a two-way connection between the Flash player and the Flash Communication Server. If used on the server, it establishes a two-way connection between two Flash Communication Servers. The NetConnection object is the transport that handles streams and SharedObjects. ActionScript objects and streams are transferred between client and server or server and server using the Real-Time Messaging protocol (RTMP).

To enable Code Hints and Code Completion in the Flash MX ActionScript Editor, use the suffix _nc in the name of the NetConnection variable.

NetConnection Methods

NetConnection.call(remoteMethod, resultObject null [, p1, ,pN])

Invokes a method defined in SSAS on the Communication Server. The method must be declared on the server within the Client object instance.

remoteMethod The name and path (if defined) of the remote method.
resultObject The object that handles properties returned to Flash by the server. The result object should have two methods ( onStatus and onResult ). Please see Appendix E,"Useful ActionScript Templates Quick Reference," to learn more about creating a resultObject handler.
p1, ... ,pN Optional parameters required by the custom client method.
NetConnection.close()

Disconnects the client from the server, cleaning up all stream and SharedObject connections.

NetConnection.connect(targetURI, [, p1 pN])

Requests a connection to a Flash Communication Server. This invokes the Application.onConnec t handler and accepts or rejects a connection based on the custom parameters you send through the connection method.

targetURI The Uniform Resource Identifier (URI) that references the Flash Communication Server, application, and instance. The URI must begin with RTMP:/ . If no server is specified, it is assumed to be a local server and only a single forward slash is required.
p1 ... pN Custom parameters that are handled by the application.onConnect method on the remote server.

NetConnection Properties

NetConnection.isConnected returns a Boolean value indicating an accepted or rejected connection.

NetConnection.uri returns the URI of the connection. This is a useful tool to use in the SharedObject.get() URI parameter to reference the NetConnection.

NetConnection Events

NetConnection.onStatus is invoked when the status of the NetConnection changes. The status will change with many events, most notably when the server accepts the connection. This event handles Information objects describing the level and a special event code. NetConnection Information objects are detailed in Appendix C.



Macromedia Flash Communication Server MX
Macromedia Flash Communication Server MX
ISBN: 0735713332
EAN: 2147483647
Year: 2002
Pages: 200
Authors: Kevin Towes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net