套件 | org.osmf.traits |
類別 | public class MediaTraitBase |
繼承 | MediaTraitBase EventDispatcher Object |
子類別 | AlternativeAudioTrait, AudioTrait, BufferTrait, DisplayObjectTrait, DRMTrait, DVRTrait, DynamicStreamTrait, LoadTrait, PlayTrait, SeekTrait, TimeTrait |
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Media traits are first-class members of the object model for a number of reasons:
- Traits allow us to isolate common aspects of different media types into reusable building blocks. For example, music and video may share a common implementation for audio. An "audio" trait can encapsulate that common implementation in such a way that it can be used for both media types, while still providing a uniform interface to these different media types.
- Different media elements may have their capabilities change dynamically over time, and traits allow us to isolate these capabilities in such a way that we can clearly express that dynamism. For example, a video player might not initially be "viewable", due to its need to be loaded before playback can begin. Rather than express this dynamism through changes to a set of methods on a monolithic media class, we can express it through the presence or absence of a trait instance on a lighter weight media class.
- Traits make compositioning scalable. (Compositioning is the ability to temporally and spatially composite collections of media.) If traits represent the overall vocabulary of the media framework, then we can implement compositioning primarily in terms of the traits, rather than in terms of the media that aggregate those traits. This approach allows developers to create new media implementations that can easily integrate with the compositioning parts of the framework without requiring changes to that framework. Our working assumption, of course, is that most (if not all) media will generally share the same vocabulary, which can be expressed through a core set of media traits.
- Traits allow for uniform, media-agnostic client classes. For example, if a client class is capable of rendering the "display object" trait, then it's capable of rendering any and all media that host that trait.
It's important to be aware of the relationship between a media trait and a media element. Some media trait implementations will be tightly coupled to a specific type of media element, while others will be generic enough to work with any media element. For example, an implementation of a "play" trait that works with video is typically going to be specific to one class of media elements, namely the class that plays video, since the playback operations will be specific to the underlying implementation of video (i.e. NetStream). On the other hand, an implementation of a "display object" trait might be able to work with any media element, since DisplayObjectTrait will use the same underlying media implementation (DisplayObject) for any media element.
屬性 | 定義自 | ||
---|---|---|---|
constructor : Object
類別物件的參照或是特定物件實體的建構函數。 | Object | ||
traitType : String [唯讀]
The MediaTraitType for this trait. | MediaTraitBase |
方法 | 定義自 | ||
---|---|---|---|
MediaTraitBase(traitType:String)
Constructor. | MediaTraitBase | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。 | EventDispatcher | ||
會將事件傳送到事件流程。 | EventDispatcher | ||
Disposes of any resources used by this trait. | MediaTraitBase | ||
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。 | EventDispatcher | ||
指出物件是否有已定義的指定屬性。 | Object | ||
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。 | Object | ||
指出指定的屬性是否存在,以及是否可列舉。 | Object | ||
會從 EventDispatcher 物件移除偵聽程式。 | EventDispatcher | ||
為迴圈作業設定動態屬性的可用性。 | Object | ||
傳回代表此物件的字串,根據地區特定慣例進行格式化。 | Object | ||
會傳回指定之物件的字串形式。 | Object | ||
會傳回指定之物件的基本值。 | Object | ||
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。 | EventDispatcher |
traitType | 屬性 |
MediaTraitBase | () | 建構函式 |
dispose | () | 方法 |
public function dispose():void
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Disposes of any resources used by this trait. Called by the framework whenever a trait is removed from a MediaElement.
Subclasses should override to do any disposal logic specific to their implementation.
Tue Jun 12 2018, 03:47 PM Z