AS3视频事件:如何在视频首次播放时触发某些内容

时间:2012-05-03 06:54:14

标签: actionscript-3 flash

我正在使用flash的视频播放器播放剪辑,自动播放设置为false。我需要在首次点击播放按钮时触发mc1播放,并在视频完成时触发mc2。

现在我知道如何使用以下方法完成触发:

videoPlayer.addEventListener(VideoEvent.COMPLETE, vidCompleteHandler);

但是我不知道视频首次播放时我需要什么视频事件,因为我不想在每次点击播放按钮时触发mc1(即如果人们点击暂停然后再次播放,我不会希望再次触发mc1。)

有人可以帮我这个吗?

1 个答案:

答案 0 :(得分:0)

首先需要将NetStream对象附加到视频对象,然后侦听特定的开始事件。它是这样的:

// create a new net connection, add event listener and connect
// to null because we don't have a media server
ncConnection = new NetConnection();
ncConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
ncConnection.connect(null);

// create a new netstream with the net connection, add event
// listener, set client to this for handling meta data and
// set the buffer time to the value from the constant
nsStream = new NetStream(ncConnection);
nsStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nsStream.client = this;
nsStream.bufferTime = BUFFER_TIME;

// attach net stream to video object on the stage
vidDisplay.attachNetStream(nsStream);

function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
    case "NetStream.Play.Start":
        yourStartFunction();
    break;
}

}

相关问题