Packageimpression.resolver
Classpublic class SoundEx
InheritanceSoundEx Inheritance flash.media.Sound

The SoundEx class extends the Sound object to support notifications for cancelled operations, general-purpose status events, and object connections for the AssetResolver.

See also

flash.media.Sound


Public Properties
 PropertyDefined By
  active : Boolean
[read-only] true if the object is currently loading data.
SoundEx
  kbps : Number
[read-only] The bitrate at which the object is loading data.
SoundEx
  lastAsset : AssetData
[read-only]
SoundEx
  lastEvent : Event
[read-only] A copy of the most recent event object dispatched by the base class.
SoundEx
  lastRequest : URLRequest
[read-only]
SoundEx
  latency : Number
[read-only] The number of milliseconds between the time that the load request was issued and loading begins.
SoundEx
  owner : *
[read-only] The owner of the object.
SoundEx
  resolver : AssetResolver
[read-only] The AssetResolver associated with the object.
SoundEx
Public Methods
 MethodDefined By
  
SoundEx(stream:URLRequest = null, context:SoundLoaderContext = null, owner:* = null, resolver:AssetResolver = null)
Creates a new instance of the SoundEx class.
SoundEx
  
close():void
[override] Closes the stream, causing any download of data to cease.
SoundEx
  
load(stream:URLRequest, context:SoundLoaderContext = null):void
[override] Initiates loading of an external MP3 file from the specified URL.
SoundEx
  
loadAsset(asset:AssetData, context:SoundLoaderContext = null):void
Begins loading an asset.
SoundEx
Events
 Event Summary Defined By
  Dispatched when the object receives a request to begin loading data.SoundEx
  Dispatched when a load operation in progress is cancelled.SoundEx
  Dispatched when the object has finished loading data.SoundEx
Property Detail
activeproperty
active:Boolean  [read-only]

true if the object is currently loading data.


Implementation
    public function get active():Boolean
kbpsproperty 
kbps:Number  [read-only]

The bitrate at which the object is loading data.

This value is calculated by dividing bytesLoaded by elapsedTime and adjusting by a fixed factor to account for TCP/IP overhead.


Implementation
    public function get kbps():Number
lastAssetproperty 
lastAsset:AssetData  [read-only]


Implementation
    public function get lastAsset():AssetData
lastEventproperty 
lastEvent:Event  [read-only]

A copy of the most recent event object dispatched by the base class.

Note that the last event does not include the ResolverEvent.BEGIN or ResolverEvent.END events. The lastEvent object is not reset when the load method is invoked.


Implementation
    public function get lastEvent():Event
lastRequestproperty 
lastRequest:URLRequest  [read-only]


Implementation
    public function get lastRequest():URLRequest
latencyproperty 
latency:Number  [read-only]

The number of milliseconds between the time that the load request was issued and loading begins.


Implementation
    public function get latency():Number
ownerproperty 
owner:*  [read-only]

The owner of the object.


Implementation
    public function get owner():*
resolverproperty 
resolver:AssetResolver  [read-only]

The AssetResolver associated with the object.

The resolver is used to retrieve the fully-qualified URI when the loadAsset method is invoked. The object also reports state change event information to the resolver during the load cycle; allowing for aggregate information to be retrieved from either the resolver and/or the ResolverInfo object for this object's owner.


Implementation
    public function get resolver():AssetResolver

See also

Constructor Detail
SoundEx()Constructor
public function SoundEx(stream:URLRequest = null, context:SoundLoaderContext = null, owner:* = null, resolver:AssetResolver = null)

Creates a new instance of the SoundEx class.

If stream parameter is not null, the load method will be invoked with the stream parameter once the object has been instanciated.

Parameters
stream:URLRequest (default = null) — The object to load.
 
context:SoundLoaderContext (default = null) — An optional SoundLoader context object, which can define the buffer time (the minimum number of milliseconds of MP3 data to hold in the Sound object's buffer) and can specify whether the application should check for a cross-domain policy file prior to loading the sound.
 
owner:* (default = null) — The object that the state information for this object should be reported to.
 
resolver:AssetResolver (default = null) — The AssetResolver to associate with this object.
Method Detail
close()method
override public function close():void

Closes the stream, causing any download of data to cease.

Any load operation in progress is immediately terminated. If a load operation was in progress, then the Event.CLOSE event is dispatched.

Unlike the Sound class, if the stream could not be closed, or the stream was not open, no error is thrown.

load()method 
override public function load(stream:URLRequest, context:SoundLoaderContext = null):void

Initiates loading of an external MP3 file from the specified URL.

The SoundEx class overrides the default behavior of the Sound object in the following manner:

  1. The kbps value is reset.
  2. If the active property value is false, it is set to true and the ResolverEvent.BEGIN event is dispatched with the stream parameter as the event's relatedObject member.
  3. The stream parameter is saved as the lastRequest, and the Sound's load method is invoked.
  4. If an error occured as a result of invoking the base class' load method, or the stream parameter is null, the ResolverEvent.END event is dispatched with the stream parameter as the event's relatedObject member.
  5. If an error occured, and the stream parameter is not null, the error is thrown.

Parameters

stream:URLRequest — The URLRequest to load.
 
context:SoundLoaderContext (default = null) — An optional SoundLoader context object, which can define the buffer time (the minimum number of milliseconds of MP3 data to hold in the Sound object's buffer) and can specify whether the application should check for a cross-domain policy file prior to loading the sound.


Throws
Error — [the error that occured] (Error).

See also

begin
end
flash.media.Sound.load()
loadAsset()method 
public function loadAsset(asset:AssetData, context:SoundLoaderContext = null):void

Begins loading an asset.

This method invokes the resolver property's getURLRequest with the asset parameter, then invokes its own load method with the returned request.

Parameters

asset:AssetData — The asset to load.
 
context:SoundLoaderContext (default = null) — An optional SoundLoader context object, which can define the buffer time (the minimum number of milliseconds of MP3 data to hold in the Sound object's buffer) and can specify whether the application should check for a cross-domain policy file prior to loading the sound.


Throws
IllegalOperationError cannot — load asset without resolver (IllegalOperationError).

See also

Event Detail
begin Event
Event Object Type: impression.events.ResolverEvent
ResolverEvent.type property = impression.events.ResolverEvent.BEGIN

Dispatched when the object receives a request to begin loading data.

This event is dispatched when the load method is invoked, either explicitly or implicitly as the result of calling the loadAsset method. This event will occur even if the request is null or cannot be loaded. This event will not occur if the active property value is true.

The ResolverEvent.BEGIN constant defines the value of the type property of a begin event object. This event has the following properties:
PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
relatedObjectThe object associated with the event. If target is a LoaderEx, SoundEx, or URLLoaderEx object, relatedObject is the instance of the URLRequest object to load. If target is a LoaderInfo object, relatedObject is the content object that originally dispatched the ResolverEvent.BEGIN event.

See also

close Event  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.CLOSE

Dispatched when a load operation in progress is cancelled.

This event is dispatched when the object is actively loading and the the close method is invoked.

See also

end Event  
Event Object Type: impression.events.ResolverEvent
ResolverEvent.type property = impression.events.ResolverEvent.END

Dispatched when the object has finished loading data.

This event is dispatched when the object is no longer actively loading data. This may be due to normal load completion, when an error occurs, or by invoking the close method.

The ResolverEvent.END constant defines the value of the type property of an end event object. This event has the following properties:
PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
relatedObjectThe object associated with the event. If target is a LoaderEx, SoundEx, or URLLoaderEx object, relatedObject is the instance of the URLRequest object to load. If target is a LoaderInfo object, relatedObject is the content object that originally dispatched the ResolverEvent.BEGIN event.

See also