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 

DisplayObjectTrait  - AS3 OSMF

Packageorg.osmf.traits
Classpublic class DisplayObjectTrait
InheritanceDisplayObjectTrait Inheritance MediaTraitBase Inheritance EventDispatcher Inheritance Object

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

DisplayObjectTrait defines the trait interface for media that expose a DisplayObject, and which may have intrinsic dimensions. The intrinsic dimensions of a piece of media refer to its dimensions without regard to those observed when it is projected onto the stage.

For an image, for example, the intrinsic dimensions are the height and width of the image as it is stored.

Use the MediaElement.hasTrait(MediaTraitType.DISPLAY_OBJECT) method to query whether a media element has a trait of this type. If hasTrait(MediaTraitType.DISPLAY_OBJECT) returns true, use the MediaElement.getTrait(MediaTraitType.DISPLAY_OBJECT) method to get an object that is of this type.

Related API Elements



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  displayObject : DisplayObject
[read-only] The media's display object.
DisplayObjectTrait
  mediaHeight : Number
[read-only] The intrinsic height of the media.
DisplayObjectTrait
  mediaWidth : Number
[read-only] The intrinsic width of the media.
DisplayObjectTrait
 InheritedtraitType : String
[read-only] The MediaTraitType for this trait.
MediaTraitBase
Public Methods
 MethodDefined By
  
DisplayObjectTrait(displayObject:DisplayObject, mediaWidth:Number = 0, mediaHeight:Number = 0)
Constructor.
DisplayObjectTrait
 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
 Inherited
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
Protected Methods
 MethodDefined By
  
Called just after the displayObject property has changed.
DisplayObjectTrait
  
Called immediately before the displayObject property is changed.
DisplayObjectTrait
  
mediaSizeChangeEnd(oldMediaWidth:Number, oldMediaHeight:Number):void
Called just after setMediaSize() has applied new mediaWidth and/or mediaHeight values.
DisplayObjectTrait
  
mediaSizeChangeStart(newMediaWidth:Number, newMediaHeight:Number):void
Called just before a call to setMediaSize().
DisplayObjectTrait
  
Defines the trait's displayObject.
DisplayObjectTrait
  
setMediaSize(mediaWidth:Number, mediaHeight:Number):void
Sets the trait's width and height.
DisplayObjectTrait
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
  Dispatched when the trait's displayObject property has changed.DisplayObjectTrait
  Dispatched when the trait's mediaWidth and/or mediaHeight property has changed.DisplayObjectTrait
Property Detail

displayObject

property
displayObject:DisplayObject  [read-only]

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

The media's display object.



Implementation
    public function get displayObject():DisplayObject

mediaHeight

property 
mediaHeight:Number  [read-only]

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

The intrinsic height of the media.



Implementation
    public function get mediaHeight():Number

mediaWidth

property 
mediaWidth:Number  [read-only]

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

The intrinsic width of the media.



Implementation
    public function get mediaWidth():Number
Constructor Detail

DisplayObjectTrait

()Constructor
public function DisplayObjectTrait(displayObject:DisplayObject, mediaWidth:Number = 0, mediaHeight:Number = 0)

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

Constructor.

Parameters
displayObject:DisplayObject
 
mediaWidth:Number (default = 0)
 
mediaHeight:Number (default = 0)
Method Detail

displayObjectChangeEnd

()method
protected function displayObjectChangeEnd(oldDisplayObject:DisplayObject):void

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

Called just after the displayObject property has changed. Dispatches the change event.

Subclasses that override should call this method to dispatch the displayObjectChange event.

Parameters

oldDisplayObject:DisplayObject — Previous displayObject value.

displayObjectChangeStart

()method 
protected function displayObjectChangeStart(newView:DisplayObject):void

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

Called immediately before the displayObject property is changed.

Subclasses can override this method to communicate the change to the media.

Parameters

newView:DisplayObject — New displayObject value.

mediaSizeChangeEnd

()method 
protected function mediaSizeChangeEnd(oldMediaWidth:Number, oldMediaHeight:Number):void

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

Called just after setMediaSize() has applied new mediaWidth and/or mediaHeight values. Dispatches the change event.

Subclasses that override should call this method to dispatch the mediaSizeChange event.

Parameters

oldMediaWidth:Number — Previous mediaWidth value.
 
oldMediaHeight:Number — Previous mediaHeight value.

mediaSizeChangeStart

()method 
protected function mediaSizeChangeStart(newMediaWidth:Number, newMediaHeight:Number):void

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

Called just before a call to setMediaSize(). Subclasses can override this method to communicate the change to the media.

Parameters

newMediaWidth:Number — New mediaWidth value.
 
newMediaHeight:Number — New mediaHeight value.

setDisplayObject

()method 
protected final function setDisplayObject(value:DisplayObject):void

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

Defines the trait's displayObject. If the displayObject is different from the one that is currently set, a displayObjectChange event will be dispatched.

Parameters

value:DisplayObject

setMediaSize

()method 
protected final function setMediaSize(mediaWidth:Number, mediaHeight:Number):void

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

Sets the trait's width and height.

Forces non numerical and negative values to zero.

If the either the width or the height differs from the previous width or height, dispatches a mediaSizeChange event.

Parameters

mediaWidth:Number — The new width.
 
mediaHeight:Number — The new height.
Event Detail

displayObjectChange

Event
Event Object Type: org.osmf.events.DisplayObjectEvent
property DisplayObjectEvent.type = org.osmf.events.DisplayObjectEvent.DISPLAY_OBJECT_CHANGE

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

Dispatched when the trait's displayObject property has changed. This occurs when a different DisplayObject is assigned to represent the media.

The DisplayObjectEvent.DISPLAY_OBJECT_CHANGE constant defines the value of the type property of the event object for a displayObjectChange event.

mediaSizeChange

Event  
Event Object Type: org.osmf.events.DisplayObjectEvent
property DisplayObjectEvent.type = org.osmf.events.DisplayObjectEvent.MEDIA_SIZE_CHANGE

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

Dispatched when the trait's mediaWidth and/or mediaHeight property has changed.

The DisplayObjectEvent.MEDIA_SIZE_CHANGE constant defines the value of the type property of the event object for a mediaSizeChange event.