如果使用VideoDisplay,那么他有一個屬性,叫cuePoints,值類型為數組,數組中的每個元素要求有兩個屬性,一個是name,類型為字符串,一個是time,類型為數字,表示觸發時間的秒數。例如下面的代碼,當播放到3s時將彈出一個對話框。這用來解決一些播放到某一時間點觸發某事件的情況。
<?xml version="1.0" encoding="utf-8"?>
<!-- LearnCurPointEvent.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.CuePointEvent;
[Bindable]
private var myCuePoints:Array = [
{ name: "first", time: 3}];
private function init():void{
this.c_mainVideoDisplay.cuePoints = myCuePoints;
this.c_mainVideoDisplay.addEventListener(CuePointEvent.CUE_POINT,cue_PointHandler);
}
private function cue_PointHandler(event:CuePointEvent):void{
c_mainVideoDisplay.pause();
Alert.show("It plays " + event.cuePointTime +"s.","",4,null,go);
}
private function go(event:Event):void{
c_mainVideoDisplay.play();
}
]]>
</mx:Script>
<mx:VideoDisplay id="c_mainVideoDisplay" width="320" height="240"
cuePointManagerClass="mx.controls.videoClasses.CuePointManager"
source="phone.flv"
autoPlay="false" />
<mx:Button label="播放" click="go(event)"/>
</mx:Application>