I just began learning AS3. I’m simply trying to play an FLV video. How do you attach the video object to the main stage? I tried but it said that “stage” was undefined.
package {
import flash.media.*;
import flash.net.*;
import flash.display.*;
public class Player {
private var vid:Video;
private var vidConnection:NetConnection;
private var vidStream:NetStream;
private var monitor:Object;
public function Player() {
this.vid = new Video();
stage.addChild(this.vid);
this.vidConnection = new NetConnection();
this.vidConnection.connect(null);
this.vidStream = new NetStream(this.vidConnection);
this.monitor = new Object();
this.monitor.onMetaData = this.onMetaData;
this.monitor.onCuePoint = this.onCuePoint;
this.vidStream.client = this.monitor;
this.vid.attachNetStream(this.vidStream);
this.vidStream.play("video.flv");
}
private function onMetaData(info:Object):void {
trace("duration:", info.duration);
}
private function onCuePoint(info:Object):void {
trace("cuepoint:", info.parameters.text);
}
private function init():void {
}
}
}