2012-05-03 42 views
0

我使用閃光燈的視頻播放器播放剪輯,自動播放設置爲false。當第一次點擊播放按鈕時,我需要觸發mc1播放,當視頻完成時觸發mc2。AS3視頻事件:如何在視頻首次播放時觸發某些內容

現在我知道該怎麼做了完整的觸發:

videoPlayer.addEventListener(VideoEvent.COMPLETE, vidCompleteHandler); 

但我不知道視頻事件,我需要在視頻首先播放,因爲我不想讓MC1被觸發每次做播放按鈕被點擊(即如果人們點擊暫停然後再次播放,我不想再次觸發mc1)。

有人可以幫助我嗎?

+0

只是添加事件偵聽器的播放按鈕,聽的點擊。 –

+0

^謝謝你的工作! – muudless

回答

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; 
} 

}

相關問題