套件 | org.osmf.elements |
類別 | public class DurationElement |
繼承 | DurationElement ProxyElement MediaElement EventDispatcher Object |
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
The DurationElement class is especially useful for creating delays in the presentation of a media composition. For example, the following code presents a sequence of videos, separated from each other by five-second delays.
var sequence:SerialElement = new SerialElement(); sequence.addChild(new VideoElement(new URLResource("http://www.example.com/video1.flv"))); sequence.addChild(new DurationElement(5)); sequence.addChild(new VideoElement(new URLResource("http://www.example.com/ad.flv"))); sequence.addChild(new DurationElement(5)); sequence.addChild(new VideoElement(new URLResource("http://www.example.com/video2.flv"))); // Assign the SerialElement to the MediaPlayer. player.media = sequence;
The following example presents a sequence of rotating banners. The delays separating the appearances of the banners are created with DurationElements. In addition, the images themselves are wrapped in DurationElements to enable them to support a duration.
// The first banner does not appear for five seconds. // Each banner is shown for 20 seconds. // There is a 15-second delay between images. var bannerSequence:SerialElement = new SerialElement(); bannerSequence.addChild(new DurationElement(5)); bannerSequence.addChild(new DurationElement(20,new ImageElement(new URLResource("http://www.example.com/banner1.jpg"))); bannerSequence.addChild(new DurationElement(15)); bannerSequence.addChild(new DurationElement(20,new ImageElement(new URLResource("http://www.example.com/banner2.jpg"))); bannerSequence.addChild(new DurationElement(15)); bannerSequence.addChild(new DurationElement(20,new ImageElement(new URLResource("http://www.example.com/banner3.jpg")));
clipStartTime
and clipEndTime
properties.
相關 API 元素
公用方法
方法 | 定義自 | ||
---|---|---|---|
Constructor. | DurationElement | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。 | EventDispatcher | ||
Adds a Metadata object to this MediaElement under the specified namespace URL. | MediaElement | ||
會將事件傳送到事件流程。 | EventDispatcher | ||
Returns the Metadata object that is stored under this MediaElement with
the specified namespace URL. | MediaElement | ||
Returns the media trait of the specified type. | MediaElement | ||
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。 | EventDispatcher | ||
指出物件是否有已定義的指定屬性。 | Object | ||
Determines whether this media element has a media trait of the
specified type. | MediaElement | ||
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。 | Object | ||
指出指定的屬性是否存在,以及是否可列舉。 | Object | ||
會從 EventDispatcher 物件移除偵聽程式。 | EventDispatcher | ||
Removes the Metadata object that was stored under this MediaElement with
the specified namespace URL. | MediaElement | ||
為迴圈作業設定動態屬性的可用性。 | Object | ||
傳回代表此物件的字串,根據地區特定慣例進行格式化。 | Object | ||
會傳回指定之物件的字串形式。 | Object | ||
會傳回指定之物件的基本值。 | Object | ||
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。 | EventDispatcher |
建構函式詳細資料
DurationElement | () | 建構函式 |
public function DurationElement(duration:Number, mediaElement:MediaElement = null)
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Constructor.
參數duration:Number — Duration of the DurationElement's TimeTrait, in seconds.
| |
mediaElement:MediaElement (default = null ) — Optional element to be wrapped by this DurationElement.
|
範例 如何使用本範例
DurationElementExample.as
package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import org.osmf.elements.BeaconElement; import org.osmf.elements.DurationElement; import org.osmf.elements.ImageElement; import org.osmf.elements.VideoElement; import org.osmf.media.MediaPlayer; import org.osmf.media.MediaPlayerSprite; import org.osmf.media.URLResource; public class DurationElementExample extends Sprite { public function DurationElementExample() { super(); stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; var mediaPlayerSprite:MediaPlayerSprite = new MediaPlayerSprite(); var imageElement:ImageElement = new ImageElement(); imageElement.resource = new URLResource("http://mediapm.edgesuite.net/strobe/content/test/train.jpg"); // Shows the image for 10 seconds. var durationElement:DurationElement = new DurationElement(10, imageElement); addChild(mediaPlayerSprite); mediaPlayerSprite.media = durationElement; } } }
Tue Jun 12 2018, 03:47 PM Z