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.
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(); } }; 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 my_video.attachVideo(sub_ns); // 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 sub_ns.play("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.