<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initPlayer()"> <mx:Script> <![CDATA[ import mx.events.VideoEvent; internal function initPlayer():void{ myVideo.source="video/今天你要嫁给我.flv"; myVideo.addEventListener(VideoEvent.COMPLETE,completeHandler); } internal function completeHandler(event:VideoEvent):void{ playBtn.label="播放"; } internal function doPlay():void{ if(!myVideo.playing){ myVideo.play(); //开始播放视频,playing属性变为true,如果之前调用过pause方法,则从上次的位置继续播放 playBtn.label="停止"; }else{ myVideo.stop(); playBtn.label="播放"; } } internal function doPause():void{ if(!myVideo.playing){ myVideo.play(); }else{ myVideo.pause(); pauseBtn.label="播放"; } } ]]> </mx:Script> <mx:Panel x="0" y="10" width="406" height="326" layout="absolute"> <mx:VideoDisplay x="10" y="0" width="366" height="183" id="myVideo" source="video/今天你要嫁给我.flv" autoPlay="false"/> <mx:VBox x="10" y="191" width="356" height="71"> <!-- progressBar视频的加载,如果在网络上运行,视频的加载需要一段时间,因些显示进度条是必要的 --> <mx:ProgressBar labelPlacement="left" source="myVideo"/> <mx:Canvas width="160" height="39"> <mx:Button x="10" y="10" label="播放" id="playBtn" click="doPlay()"/> <mx:Button x="102" y="10" label="暂停" id="pauseBtn" click="doPause()"/> </mx:Canvas> </mx:VBox> </mx:Panel> </mx:Application>