80
Client-Side ActionScript Language Reference
Returns
A NetStream object.
Description
Constructor; creates a stream that can be used for publishing (sending) or playing (receiving)
data through the specified NetConnection object.
You can’t publish and play data over the same stream at the same time. For example, if you are
publishing on a stream and then call
NetStream.play()
, an implicit
NetStream.close()
method is called; the publishing stream then becomes a subscribing stream.
However, you can create multiple streams that run simultaneously over the same connection:
one stream publishes and another stream plays.
Example
The following example shows how a publishing client and a subscribing client can connect to
the Flash Media Server and then open an application stream for sending (publishing) or
receiving (playing) data over this connection.
// Publishing client contains this code.
my_nc:NetConnection = new NetConnection(); // create NetConnection
object
my_nc.connect("rtmp://myRTMPServer.myDomain.com/app"); // connect to server
my_ns:NetStream = new NetStream(my_nc); // open app stream within my_nc
my_ns.publish("myWeddingVideo"); // publish data over this stream
// Subscribing client contains this code.
/* Note that the connection and stream names are the same as those used by
the publishing client. This is neither required nor prohibited,because
the scripts are running on different machines.However,the parameters used
with connect() and play() below must be the same as those used with
connect() and publish() above. */
my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://myRTMPServer.myDomain.com/app");
my_ns:NetStream = new NetStream(my_nc);
my_ns.play("myWeddingVideo");
For more examples, see the
NetStream class
entry and
Video.attachVideo()
.
See also
NetConnection class
,
NetStream.attachAudio()
,
NetStream.attachVideo()
,
NetStream.play()
,
NetStream.publish()
,
Video.attachVideo()