Packagecom.whirled.contrib.sound
Classpublic class SoundController
InheritanceSoundController Inheritance flash.events.EventDispatcher



Public Properties
 PropertyDefined by
  backgroundVolume : Number
SoundController
  effectsVolume : Number
SoundController
Protected Properties
 PropertyDefined by
  _backgroundVolume : Number
SoundController
  _channels : Map
SoundController
  _effectsVolume : Number
SoundController
  _eventMgr : EventHandlerManager
SoundController
  _levelPackMgr : LevelPackManager
SoundController
  _soundFactory : SoundFactory
SoundController
  _tickBindings : Array
SoundController
  _timer : Timer
SoundController
  _track : SoundChannel
SoundController
  _trackName : String
SoundController
  _tracks : Map
SoundController
Public Methods
 MethodDefined by
  
SoundController(factory:SoundFactory = null, initialBackgroundVolume:Number = 0.5, initialEffectsVolume:Number = 0.5, levelPackMgr:LevelPackManager = null)
SoundController
  
playEffect(effect:SoundEffect, id:int = 0, location:Point = null):void
Location indicates how far off center the sound should feel to the user.
SoundController
  
shutdown():void
SoundController
  
startBackgroundMusic(name:String, crossfade:Boolean = true, loop:Boolean = true):void
SoundController
  
stopBackgroundMusic(fadeOut:Boolean = true):void
SoundController
  
stopEffect(effect:SoundEffect, id:int):void
SoundController
Protected Methods
 MethodDefined by
  
addBinding(binding:Function):void
SoundController
  
bindChannelRemoval(key:String):Function
SoundController
  
bindFadein(channel:SoundChannel, type:SoundType):Function
SoundController
  
bindFadeout(channel:SoundChannel):Function
SoundController
  
getKey(effect:SoundEffect, id:int):String
SoundController
  
loopTrack():void
SoundController
  
playSound(sound:Sound, volume:Number, pan:Number = 0):SoundChannel
SoundController
  
tick(... ignored):void
SoundController
Events
 EventSummaryDefined by
    SoundController
Public Constants
 ConstantDefined by
  BACKGROUND_MUSIC_COMPLETE : String = "backgroundMusicComplete"
[static]
SoundController
  SOUND_ENABLED : Boolean = true
[static]
SoundController
Protected Constants
 ConstantDefined by
  DISTANCE_NORMALIZE : Number
[static]
SoundController
  FADE_TIME : int = 3000
[static]
SoundController
Property detail
_backgroundVolumeproperty
protected var _backgroundVolume:Number
backgroundVolumeproperty 
backgroundVolume:Number  [read-write]Implementation
    public function get backgroundVolume():Number
    public function set backgroundVolume(value:Number):void
_channelsproperty 
protected var _channels:Map
_effectsVolumeproperty 
protected var _effectsVolume:Number
effectsVolumeproperty 
effectsVolume:Number  [read-write]Implementation
    public function get effectsVolume():Number
    public function set effectsVolume(value:Number):void
_eventMgrproperty 
protected var _eventMgr:EventHandlerManager
_levelPackMgrproperty 
protected var _levelPackMgr:LevelPackManager
_soundFactoryproperty 
protected var _soundFactory:SoundFactory
_tickBindingsproperty 
protected var _tickBindings:Array
_timerproperty 
protected var _timer:Timer
_trackproperty 
protected var _track:SoundChannel
_trackNameproperty 
protected var _trackName:String
_tracksproperty 
protected var _tracks:Map
Constructor detail
SoundController()constructor
public function SoundController(factory:SoundFactory = null, initialBackgroundVolume:Number = 0.5, initialEffectsVolume:Number = 0.5, levelPackMgr:LevelPackManager = null)

Parameters
factory:SoundFactory (default = null) — The sound factory to use to fetch sound effects. If none is provided, a default ApplicationDomainSoundFactory is created that uses the currentDomain
 
initialBackgroundVolume:Number (default = 0.5) — The initial value of the background volume
 
initialEffectsVolume:Number (default = 0.5) — The initial volume of sound effects
 
levelPackMgr:LevelPackManager (default = null) — Background music is defined as MP3s that are loaded out of game level packs. If no LevelPackManager is provided, LevelPacks.getGlobalManager() is used.
Method detail
addBinding()method
protected function addBinding(binding:Function):voidParameters
binding:Function
bindChannelRemoval()method 
protected function bindChannelRemoval(key:String):FunctionParameters
key:String

Returns
Function
bindFadein()method 
protected function bindFadein(channel:SoundChannel, type:SoundType):FunctionParameters
channel:SoundChannel
 
type:SoundType

Returns
Function
bindFadeout()method 
protected function bindFadeout(channel:SoundChannel):FunctionParameters
channel:SoundChannel

Returns
Function
getKey()method 
protected function getKey(effect:SoundEffect, id:int):StringParameters
effect:SoundEffect
 
id:int

Returns
String
loopTrack()method 
protected function loopTrack():void
playEffect()method 
public function playEffect(effect:SoundEffect, id:int = 0, location:Point = null):void

Location indicates how far off center the sound should feel to the user. The pure distance from (0, 0) indicates the overall volume level that the effect will play at, and the x value indicates how far left/right the sound will be panned. The location point x and y values should be normalized to a [-1, 1] scale.

Parameters
effect:SoundEffect
 
id:int (default = 0)
 
location:Point (default = null)
playSound()method 
protected function playSound(sound:Sound, volume:Number, pan:Number = 0):SoundChannelParameters
sound:Sound
 
volume:Number
 
pan:Number (default = 0)

Returns
SoundChannel
shutdown()method 
public function shutdown():void
startBackgroundMusic()method 
public function startBackgroundMusic(name:String, crossfade:Boolean = true, loop:Boolean = true):voidParameters
name:String
 
crossfade:Boolean (default = true)
 
loop:Boolean (default = true)
stopBackgroundMusic()method 
public function stopBackgroundMusic(fadeOut:Boolean = true):voidParameters
fadeOut:Boolean (default = true)
stopEffect()method 
public function stopEffect(effect:SoundEffect, id:int):voidParameters
effect:SoundEffect
 
id:int
tick()method 
protected function tick(... ignored):voidParameters
... ignored
Event detail
backgroundMusicCompleteevent 
Event object type: flash.events.Event

Constant detail
BACKGROUND_MUSIC_COMPLETEconstant
public static const BACKGROUND_MUSIC_COMPLETE:String = "backgroundMusicComplete"
DISTANCE_NORMALIZEconstant 
protected static const DISTANCE_NORMALIZE:Number
FADE_TIMEconstant 
protected static const FADE_TIME:int = 3000
SOUND_ENABLEDconstant 
public static const SOUND_ENABLED:Boolean = true