ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
org.osmf.traits 

MediaTraitBase  - AS3 OSMF

Packageorg.osmf.traits
Classpublic class MediaTraitBase
InheritanceMediaTraitBase Inheritance EventDispatcher Inheritance Object
Subclasses AlternativeAudioTrait, AudioTrait, BufferTrait, DisplayObjectTrait, DRMTrait, DVRTrait, DynamicStreamTrait, LoadTrait, PlayTrait, SeekTrait, TimeTrait

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

A MediaTraitBase is the encapsulation of a trait or capability that's inherent to a MediaElement. The sum of all traits on a media element define the overall capabilities of the media element.

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.



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  traitType : String
[read-only] The MediaTraitType for this trait.
MediaTraitBase
Public Methods
 MethodDefined By
  
Constructor.
MediaTraitBase
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
 Inherited
Dispatches an event into the event flow.
EventDispatcher
  
Disposes of any resources used by this trait.
MediaTraitBase
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
Property Detail

traitType

property
traitType:String  [read-only]

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

The MediaTraitType for this trait.



Implementation
    public function get traitType():String
Constructor Detail

MediaTraitBase

()Constructor
public function MediaTraitBase(traitType:String)

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Constructor.

Parameters
traitType:String — The MediaTraitType for this trait. All possible values are described on the MediaTraitType enumeration.
Method Detail

dispose

()method
public function dispose():void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: 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.