Packagevegas.media
Classpublic class CoreSound
InheritanceCoreSound Inheritance flash.media.Sound
Implements Action, ISound, Resumable, Startable, Stoppable

The CoreSound class extends the flash.media.Sound class and implements the Identifiable, Lockable and Logable interfaces.

Example :

     // See in the library of this fla file the BipSound Sound symbol and this linkage class id.
     
     import system.events.ActionEvent ;
     
     import vegas.date.Time ;
     import vegas.events.SoundEvent ;
     import vegas.media.CoreSound   ;
     
     import flash.media.SoundChannel ;
     
     var debug:Function = function( e:ActionEvent ):void
     {
         trace(e) ;
     }
     
     var soundComplete:Function = function( e:Event ):void
     {
         var time:Time = new Time( (e.target as CoreSound).length ) ;
         trace( e.type + " duration " + time.getMilliseconds(2) + " ms" ) ;
     }
     
     var soundUpdate:Function = function( e:SoundEvent ):void
     {
         trace( e.type + " volume:" + e.soundTransform.volume ) ;
     }
     
     var sound:CoreSound = new BipSound() ;
     
     sound.addEventListener( Event.SOUND_COMPLETE    , soundComplete ) ;
     sound.addEventListener( SoundEvent.SOUND_UPDATE , soundUpdate   ) ;
     
     sound.addEventListener( ActionEvent.FINISH , debug ) ;
     sound.addEventListener( ActionEvent.LOOP   , debug ) ;
     sound.addEventListener( ActionEvent.STOP   , debug ) ;
     sound.addEventListener( ActionEvent.START  , debug ) ;
     
     sound.volume = 0.6 ;
     
     // sound.looping = true ;
     
     sound.play() ;
     



Public Properties
 PropertyDefined By
  channel : SoundChannel
[read-only] The SoundChannel object of this CoreSound object.
CoreSound
  DEFAULT_DELAY : uint = 150
[static] The default delay value of the internal timer of the CoreSound objects in milliseconds.
CoreSound
  finishIt : Signaler
This signal emit when the notifyFinished method is invoked.
CoreSound
  leftPeak : Number
[read-only] The current amplitude (volume) of the left channel, from 0 (silent) to 1 (full amplitude).
CoreSound
  logger : Logger
Determinates the internal ILogger reference of this Logable object.
CoreSound
  looping : Boolean
The flag to determinate if the Action object is looped.
CoreSound
  muteIt : Signaler
This signal emit when the sound is muted.
CoreSound
  pan : Number
The left-to-right panning of the sound, ranging from -1 (full pan left) to 1 (full pan right).
CoreSound
  pausing : Boolean
[read-only] (read-only) Returns true if the process is in pause.
CoreSound
  phase : String
[read-only] The current phase of the action.
CoreSound
  position : Number
[read-only] The current position of the playhead within the sound.
CoreSound
  rightPeak : Number
[read-only] The current amplitude (volume) of the right channel, from 0 (silent) to 1 (full amplitude).
CoreSound
  running : Boolean
[read-only] Returns true if the process is in progress.
CoreSound
  soundTransform : SoundTransform
The SoundTransform object assigned to the sound channel.
CoreSound
  startIt : Signaler
This signal emit when the notifyStarted method is invoked.
CoreSound
  unmuteIt : Signaler
This signal emit when the sound is unmuted.
CoreSound
  volume : Number
The volume, ranging from 0 (silent) to 1 (full volume).
CoreSound
Public Methods
 MethodDefined By
  
CoreSound(stream:URLRequest = null, context:SoundLoaderContext = null)
Creates a new CoreSound instance.
CoreSound
  
clone():*
Returns the shallow copy of the object.
CoreSound
  
isLocked():Boolean
Returns true if the object is locked.
CoreSound
  
isMuted():Boolean
Returns true if the sound is muted.
CoreSound
  
load(stream:URLRequest, context:SoundLoaderContext = null):void
[override] Initiates loading of an external MP3 file from the specified URL.
CoreSound
  
lock():void
Locks the object.
CoreSound
  
mute():void
Mute the sound.
CoreSound
  
Notify an ActionEvent when the process is finished.
CoreSound
  
Notify an ActionEvent when the process is started.
CoreSound
  
pause():Boolean
Pauses playback of the Sound.
CoreSound
  
play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannel
[override] Generates a new SoundChannel object to play back the sound.
CoreSound
  
registerEventListener(type:String, listener:*, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an system.events.EventListener object with an system.events.EventDispatcher object so that the listener receives notification of an event.
CoreSound
  
resume():void
Resumes playback of the sound that is paused (if the pausing property is true).
CoreSound
  
run(... arguments):void
Run the process.
CoreSound
  
start():void
Stars the sound.
CoreSound
  
stop():void
Stops the sound playing in the channel.
CoreSound
  
Pauses or resumes playback of the sound.
CoreSound
  
toSource(indent:int = 0):String
Returns the String source representation of this object.
CoreSound
  
unlock():void
Unlocks the sound.
CoreSound
  
unmute():void
Unmute the sound.
CoreSound
  
unregisterEventListener(type:String, listener:*, useCapture:Boolean = false):void
Removes an system.events.EventListener from the system.events.EventDispatcher object.
CoreSound
Protected Methods
 MethodDefined By
  
Notify an ActionEvent when the process of the sound is changed.
CoreSound
  
Notify an ActionEvent when the process is looped.
CoreSound
  
Notify an ActionEvent when the process is stopped.
CoreSound
  
Notify an ActionEvent when the process is resumed.
CoreSound
  
Notify an ActionEvent when the process is stopped.
CoreSound
Events
 Event Summary Defined By
  Dispatched when a process is finished.CoreSound
  Dispatched when a process is started.CoreSound
Property Detail
channelproperty
channel:SoundChannel  [read-only]

The SoundChannel object of this CoreSound object.


Implementation
    public function get channel():SoundChannel
DEFAULT_DELAYproperty 
public static var DEFAULT_DELAY:uint = 150

The default delay value of the internal timer of the CoreSound objects in milliseconds.

finishItproperty 
finishIt:Signaler

This signal emit when the notifyFinished method is invoked.


Implementation
    public function get finishIt():Signaler
    public function set finishIt(value:Signaler):void
leftPeakproperty 
leftPeak:Number  [read-only]

The current amplitude (volume) of the left channel, from 0 (silent) to 1 (full amplitude). If the value is NaN, the internal SoundChannel is 'null'.


Implementation
    public function get leftPeak():Number
loggerproperty 
logger:Logger

Determinates the internal ILogger reference of this Logable object.


Implementation
    public function get logger():Logger
    public function set logger(value:Logger):void
loopingproperty 
public var looping:Boolean

The flag to determinate if the Action object is looped.

muteItproperty 
muteIt:Signaler

This signal emit when the sound is muted.


Implementation
    public function get muteIt():Signaler
    public function set muteIt(value:Signaler):void
panproperty 
pan:Number

The left-to-right panning of the sound, ranging from -1 (full pan left) to 1 (full pan right). A value of 0 represents no panning (balanced center between right and left).


Implementation
    public function get pan():Number
    public function set pan(value:Number):void
pausingproperty 
pausing:Boolean  [read-only]

(read-only) Returns true if the process is in pause.


Implementation
    public function get pausing():Boolean
phaseproperty 
phase:String  [read-only]

The current phase of the action.


Implementation
    public function get phase():String

See also

positionproperty 
position:Number  [read-only]

The current position of the playhead within the sound. If the value is NaN, the internal SoundChannel is 'null'.


Implementation
    public function get position():Number
rightPeakproperty 
rightPeak:Number  [read-only]

The current amplitude (volume) of the right channel, from 0 (silent) to 1 (full amplitude). If the value is NaN, the internal SoundChannel is 'null'.


Implementation
    public function get rightPeak():Number
runningproperty 
running:Boolean  [read-only]

Returns true if the process is in progress.


Implementation
    public function get running():Boolean
soundTransformproperty 
soundTransform:SoundTransform

The SoundTransform object assigned to the sound channel. A SoundTransform object includes properties for setting volume, panning, left speaker assignment, and right speaker assignment.


Implementation
    public function get soundTransform():SoundTransform
    public function set soundTransform(value:SoundTransform):void
startItproperty 
startIt:Signaler

This signal emit when the notifyStarted method is invoked.


Implementation
    public function get startIt():Signaler
    public function set startIt(value:Signaler):void
unmuteItproperty 
unmuteIt:Signaler

This signal emit when the sound is unmuted.


Implementation
    public function get unmuteIt():Signaler
    public function set unmuteIt(value:Signaler):void
volumeproperty 
volume:Number

The volume, ranging from 0 (silent) to 1 (full volume).


Implementation
    public function get volume():Number
    public function set volume(value:Number):void
Constructor Detail
CoreSound()Constructor
public function CoreSound(stream:URLRequest = null, context:SoundLoaderContext = null)

Creates a new CoreSound instance.

Parameters
stream:URLRequest (default = null) — The URL request that points to an external MP3 file.
 
context:SoundLoaderContext (default = null) — The SoundLoaderContext Minimum number of milliseconds of MP3 data to hold in the Sound object's buffer. The Sound object waits until it has at least this much data before beginning playback and before resuming playback after a network stall. The default value is 1000 (one second).
Method Detail
clone()method
public function clone():*

Returns the shallow copy of the object.

Returns
* — the shallow copy of the object.
isLocked()method 
public function isLocked():Boolean

Returns true if the object is locked.

Returns
Booleantrue if the object is locked.
isMuted()method 
public function isMuted():Boolean

Returns true if the sound is muted.

Returns
Booleantrue if the sound is muted.
load()method 
override public function load(stream:URLRequest, context:SoundLoaderContext = null):void

Initiates loading of an external MP3 file from the specified URL. If you provide a valid URLRequest object to the Sound constructor, the constructor calls Sound.load() for you. You only need to call Sound.load() yourself if you don't pass a valid URLRequest object to the Sound constructor or you pass a null value.

Parameters

stream:URLRequest
 
context:SoundLoaderContext (default = null)

lock()method 
public function lock():void

Locks the object.

mute()method 
public function mute():void

Mute the sound.

notifyChange()method 
protected function notifyChange():void

Notify an ActionEvent when the process of the sound is changed.

notifyFinished()method 
public function notifyFinished():void

Notify an ActionEvent when the process is finished.

notifyLooped()method 
protected function notifyLooped():void

Notify an ActionEvent when the process is looped.

notifyPaused()method 
protected function notifyPaused():void

Notify an ActionEvent when the process is stopped.

notifyResumed()method 
protected function notifyResumed():void

Notify an ActionEvent when the process is resumed.

notifyStarted()method 
public function notifyStarted():void

Notify an ActionEvent when the process is started.

notifyStopped()method 
protected function notifyStopped():void

Notify an ActionEvent when the process is stopped.

pause()method 
public function pause():Boolean

Pauses playback of the Sound.

Returns
Booleantrue if the pause method can be use (the internal SoundChannel of this Sound object is not null and not is "pausing").
play()method 
override public function play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannel

Generates a new SoundChannel object to play back the sound.

Parameters

startTime:Number (default = 0) — The initial position in milliseconds at which playback should start.
 
loops:int (default = 0) — Defines the number of times a sound loops back to the startTime value before the sound channel stops playback.
 
sndTransform:SoundTransform (default = null) — Defines the number of times a sound loops back to the startTime value before the sound channel stops playback.

Returns
SoundChannel — A SoundChannel object, which you use to control the sound. This method returns null if you have no sound card or if you run out of available sound channels. The maximum number of sound channels available at once is 32.
registerEventListener()method 
public function registerEventListener(type:String, listener:*, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Registers an system.events.EventListener object with an system.events.EventDispatcher object so that the listener receives notification of an event.

Parameters

type:String
 
listener:*
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)

resume()method 
public function resume():void

Resumes playback of the sound that is paused (if the pausing property is true).

run()method 
public function run(... arguments):void

Run the process.

Parameters

... arguments

start()method 
public function start():void

Stars the sound.

stop()method 
public function stop():void

Stops the sound playing in the channel.

togglePause()method 
public function togglePause():void

Pauses or resumes playback of the sound. You could use this method to let users pause or resume playback by pressing a single button.

toSource()method 
public function toSource(indent:int = 0):String

Returns the String source representation of this object.

Parameters

indent:int (default = 0)

Returns
String — the String source representation of this object.
unlock()method 
public function unlock():void

Unlocks the sound.

unmute()method 
public function unmute():void

Unmute the sound.

unregisterEventListener()method 
public function unregisterEventListener(type:String, listener:*, useCapture:Boolean = false):void

Removes an system.events.EventListener from the system.events.EventDispatcher object.

Parameters

type:String
 
listener:*
 
useCapture:Boolean (default = false)

Event Detail
finish Event
Event Object Type: system.events.ActionEvent
ActionEvent.type property = system.events.ActionEvent.FINISH

Dispatched when a process is finished.

The name of the event when the process is finished.

See also

start Event  
Event Object Type: system.events.ActionEvent
ActionEvent.type property = system.events.ActionEvent.START

Dispatched when a process is started.

The name of the event when the process is started.

See also