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 

LoadTrait  - AS3 OSMF

Packageorg.osmf.traits
Classpublic class LoadTrait
InheritanceLoadTrait Inheritance MediaTraitBase Inheritance EventDispatcher Inheritance Object

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

LoadTrait defines the trait interface for media that must be loaded before it can be presented. It can also be used as the base class for a more specific LoadTrait subclass.

If hasTrait(MediaTraitType.LOAD) returns true, use the MediaElement.getTrait(MediaTraitType.LOAD) method to get an object of this type.

Related API Elements



Public Properties
 PropertyDefined By
  bytesLoaded : Number
[read-only] The number of bytes of data that have been loaded.
LoadTrait
  bytesTotal : Number
[read-only] The total size in bytes of the data being loaded.
LoadTrait
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  loadState : String
[read-only] The load state of this trait.
LoadTrait
  resource : MediaResourceBase
[read-only] Resource representing the piece of media to be loaded into this LoadTrait.
LoadTrait
 InheritedtraitType : String
[read-only] The MediaTraitType for this trait.
MediaTraitBase
Public Methods
 MethodDefined By
  
Constructor.
LoadTrait
 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
  
Loads this the media into this LoadTrait.
LoadTrait
 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
  
Unloads this LoadTrait.
LoadTrait
 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 bytesLoaded property has changed.
LoadTrait
  
Called immediately before the bytesLoaded property is changed.
LoadTrait
  
Called just after the bytesTotal property has changed.
LoadTrait
  
Called immediately before the bytesTotal property is changed.
LoadTrait
  
Called just after the loadState property is change.
LoadTrait
  
Called immediately before the loadState property is changed.
LoadTrait
  
Sets the number of bytes of data that have been loaded.
LoadTrait
  
Sets the total size in bytes of the data being loaded.
LoadTrait
  
Sets the load state for this LoadTrait.
LoadTrait
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
  Dispatched when total size in bytes of data being loaded has changed.LoadTrait
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
  Dispatched when the state of the LoadTrait has changed.LoadTrait
Property Detail

bytesLoaded

property
bytesLoaded:Number  [read-only]

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

The number of bytes of data that have been loaded.



Implementation
    public function get bytesLoaded():Number

bytesTotal

property 
bytesTotal:Number  [read-only]

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

The total size in bytes of the data being loaded.



Implementation
    public function get bytesTotal():Number

loadState

property 
loadState:String  [read-only]

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

The load state of this trait. See LoadState for possible values.



Implementation
    public function get loadState():String

resource

property 
resource:MediaResourceBase  [read-only]

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

Resource representing the piece of media to be loaded into this LoadTrait.



Implementation
    public function get resource():MediaResourceBase
Constructor Detail

LoadTrait

()Constructor
public function LoadTrait(loader:LoaderBase, resource:MediaResourceBase)

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

Constructor.

Parameters
loader:LoaderBase — The LoaderBase instance that will be used to load the media for the media element that owns this trait.
 
resource:MediaResourceBase — The MediaResourceBase instance that represents the media resource to be loaded.
Method Detail

bytesLoadedChangeEnd

()method
protected function bytesLoadedChangeEnd():void

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

Called just after the bytesLoaded property has changed.

bytesLoadedChangeStart

()method 
protected function bytesLoadedChangeStart(newValue:Number):void

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

Called immediately before the bytesLoaded property is changed.

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

Parameters

newValue:Number — New bytesLoaded value.

bytesTotalChangeEnd

()method 
protected function bytesTotalChangeEnd():void

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

Called just after the bytesTotal property has changed. Dispatches the bytesTotalChange event.

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

bytesTotalChangeStart

()method 
protected function bytesTotalChangeStart(newValue:Number):void

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

Called immediately before the bytesTotal property is changed.

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

Parameters

newValue:Number — New bytesTotal value.

load

()method 
public function load():void

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

Loads this the media into this LoadTrait. Updates the load state. Dispatches the loadStateChange event with every state change.

Typical states are LOADING while the media is loading, READY after it has successfully completed loading, and LOAD_ERROR if it fails to complete loading.

If the LoadState is LOADING or READY when the method is called, throws an error.


Throws
IllegalOperationError — If this trait is unable to load itself or if the LoadState is LOADING or READY.

Related API Elements

loadStateChangeEnd

()method 
protected function loadStateChangeEnd():void

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

Called just after the loadState property is change.

loadStateChangeStart

()method 
protected function loadStateChangeStart(newState:String):void

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

Called immediately before the loadState property is changed.

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

Parameters

newState:String — New loadState value.

setBytesLoaded

()method 
protected final function setBytesLoaded(value:Number):void

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

Sets the number of bytes of data that have been loaded.

Parameters

value:Number

Throws
ArgumentError — If value is negative, NaN, or greater than bytesTotal.

setBytesTotal

()method 
protected final function setBytesTotal(value:Number):void

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

Sets the total size in bytes of the data being loaded.

Parameters

value:Number

Throws
ArgumentError — If value is negative or smaller than bytesLoaded.

setLoadState

()method 
protected final function setLoadState(newState:String):void

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

Sets the load state for this LoadTrait.

Parameters

newState:String

unload

()method 
public function unload():void

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

Unloads this LoadTrait. Updates the load state. Dispatches the loadStateChange event with every state change.

Typical states are UNLOADING while the media is unloading, UNINITIALIZED after it has successfully completed unloading, and LOAD_ERROR if it fails to complete unloading.

If the LoadState is not READY when the method is called, throws an error.


Throws
IllegalOperationError — If this trait is unable to unload itself, or if the LoadState is not READY.

Related API Elements

Event Detail

bytesTotalChange

Event
Event Object Type: org.osmf.events.LoadEvent
property LoadEvent.type = org.osmf.events.LoadEvent.BYTES_TOTAL_CHANGE

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

Dispatched when total size in bytes of data being loaded has changed.

The LoadEvent.BYTES_TOTAL_CHANGE constant defines the value of the type property of the event object for a bytesTotalChange event.

loadStateChange

Event  
Event Object Type: org.osmf.events.LoadEvent
property LoadEvent.type = org.osmf.events.LoadEvent.LOAD_STATE_CHANGE

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

Dispatched when the state of the LoadTrait has changed.

The LoadEvent.LOAD_STATE_CHANGE constant defines the value of the type property of the event object for a loadStateChange event.