The NetConnection class creates a two-way connection between a client and
a server. The client can be a Flash Player or AIR application. The server
can be a web server, Flash Media Server, an application server running
Flash Remoting, or the <a
Stratus service. Call
NetConnection.connect() to establish the
connection. Use the NetStream class to send streams of media and data over
For security information about loading content and data into Flash Player
and AIR, see the following:
- To load content and data into Flash Player from a web server or from a local location, see <a href="http://www.adobe.com/go/devnet_security_en" scope="external">Flash Player Developer Center: Security.
- To load content and data into Flash Player and AIR from Flash Media Server, see the <a href="http://www.adobe.com/support/flashmediaserver" scope="external">Flash Media Server documentation.
- To load content and data into AIR, see the <a href="http://www.adobe.com/devnet/air/" scope="external">Adobe AIR Developer Center.
To write callback methods for this class, extend the class and define the
callback methods in the subclass, or assign the
client property to an
object and define the callback methods on that object.
@event asyncError Dispatched when an exception is thrown asynchronously
נthat is, from native asynchronous code.
@event ioError Dispatched when an input or output error occurs that
causes a network operation to fail.
@event netStatus Dispatched when a NetConnection object is reporting
its status or error condition. The `netStatus` event contains an `info` property, which is an information object that contains specific information about the event, such as whether a connection attempt succeeded or failed.
@event securityError Dispatched if a call to NetConnection.call() attempts
to connect to a server outside the caller's security sandbox.
The default object encoding for NetConnection objects. When an object
is written to or read from binary data, the
property indicates which Action Message Format (AMF) version is used
to serialize the data: the ActionScript 3.0 format
ObjectEncoding.AMF3) or the ActionScript 1.0 and ActionScript 2.0
The default value is
NetConnection.defaultObjectEncoding does not affect existing
NetConnection instances; it affects only instances that are created
To set an object's encoding separately (rather than setting object
encoding for the entire application), set the
property of the NetConnection object instead.
For more detailed information, see the description of the
connect (command:String, ?p1:Unknown, ?p2:Unknown, ?p3:Unknown, ?p4:Unknown, ?p5:Unknown):Void
Adds a context header to the Action Message Format (AMF) packet
structure. This header is sent with every future AMF packet. If you
NetConnection.addHeader() using the same name, the new header
replaces the existing header, and the new header persists for the
duration of the NetConnection object. You can remove a header by
NetConnection.addHeader() with the name of the header to
remove an undefined object.
Identifies the header and the ActionScript object data associated with it.
A value of
Any ActionScript object.
staticinline read onlyCONNECT_SUCCESS:String = "NetConnection.Connect.Success"