package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.media.Video; import flash.net.NetConnection; import flash.net.NetStream; // 播放FLV视频 public class Main extends Sprite { var stream:NetStream; public function Main():void { // 第一步:创建通道,打开通道 var conn:NetConnection = new NetConnection(); conn.connect( null); // 第二步:创建流处理,指定回调函数为本身 stream = new NetStream(conn); var obj: Object = new Object(); stream.client = obj; // 第三步:视频流的呈现,绑定视频流 var video:Video = new Video(200,150); video.attachNetStream(stream); this.addChild(video); stream.play("sp.flv"); // 用按钮控制视频播放和停止 var s:Sprite = new Sprite(); s.graphics.beginFill(0xff0000); s.graphics.drawRect(0,0,50,50); s.graphics.endFill(); s.y = 150; this.addChild(s); s.addEventListener(MouseEvent.CLICK, an); } private function an(evt:MouseEvent):void { stream.togglePause(); } } }