Subscribe to a Live or Recorded Stream

The script in Listing E.4 subscribes to, or receives, a live or prerecorded video (FLV) stream that is available within the application instance's streams folder.

Listing E.4 Flash ActionScript for Subscribing to or Receiving a Video Stream
nc = new NetConnection();
nc.onStatus = function(info) {
      trace("LEVEL: "+info.level+"  CODE: "+info.code);
      if (info.code == "NetConnection.Connect.Success") {
            // Call a function to setup the NetStream Subscription
startStreamSubscribe = function () {
      // that exists on the Flash Stage.
      // attach a NetStream to the variable, sub_ns
      sub_ns = new NetStream(nc);
      // attach the Subscription source to a Video Object on the stage
      // Start the stream, "serverStream", (-2) if the live source is not available,
      // look for a recored stream of the same name.  (-1)Play until the stream is over"serverStream", -2, -1);
nc.connect("rtmp://localhost/myApplication/myInstance", "Tracey Davis", "Bert");

The SSAS ActionScript template in Listing E.2 can be used with this ActionScript.

    Part I: 10 Quick Steps for Getting Started