- var nc:NetConnection=New NetConnection();
- nc.connect(null);
- var ns:NetStream=new NetStream(nc);
var vid:Video=new Video(320,240);
this.addChild(vid);
Once we have created the video object we now need to connect it to the NetStream object. In AS3.0 we do this by using a method called attachNetStream(). If you want to attach a webcam to the video object you would use the attachCamera() method. Once the NetStream is attached we can begin playing an external FLV the same as before by calling the NetStream.play() method. e.g.
vid.attachNetStream(ns);
ns.play("test.flv");
for responding the events from the NetStream class, First off, you have to provide a callback function for the on MetaData event or Flash will throw errors at you. You need to create an Object that will act as the NetStream's client for the callback event. Once you have setup the onMetaData function for this object you need to set the NetStream client property so it knows where to look. If your FLV contains embedded cue points then you will also need to create an onCuePoint function to handle that call back event.
var netClient:Object=new Object();
netClient.onMetaData=function(meta:Object)
{
trace(meta.duration);
}
ns.client=netClient;
In order to recieve status messages we use the NetStream.addEventListener() method to define a listener functionto respond to this event. e.g.
ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);
function netstat(stats:NetStatusEvent)
{
trace(status.info.code);
}
No comments:
Post a Comment
Suggestions are heartily awaited.