Packageorg.flixel.system
Classpublic class FlxSound
InheritanceFlxSound Inheritance FlxBasic Inheritance Object

This is the universal flixel sound object, used for streaming, music, and sound effects.



Public Properties
 PropertyDefined By
 Inheritedactive : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_ACTIVECOUNT : uint
[static]
FlxBasic
 Inheritedalive : Boolean
Useful state for many game objects - "dead" (!alive) vs alive.
FlxBasic
  amplitude : Number
Stores the average wave amplitude of both stereo channels
FlxSound
  amplitudeLeft : Number
Just the amplitude of the left stereo channel
FlxSound
  amplitudeRight : Number
Just the amplitude of the left stereo channel
FlxSound
  artist : String
The ID3 artist name.
FlxSound
 Inheritedexists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup.
FlxBasic
 InheritedID : int
IDs seem like they could be pretty useful, huh?
FlxBasic
  name : String
The ID3 song name.
FlxSound
  survive : Boolean
Whether or not this sound should be automatically destroyed when you switch states.
FlxSound
 Inheritedvisible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_VISIBLECOUNT : uint
[static]
FlxBasic
  volume : Number
Set volume to a value between 0 and 1 to change how this sound is.
FlxSound
  x : Number
FlxSound
  y : Number
FlxSound
Protected Properties
 PropertyDefined By
  _amplitudeCallback : Function
FlxSound
  _amplitudeMonitor : FlxMonitor
FlxSound
  _amplitudeThreshold : Number
FlxSound
  _channel : SoundChannel
FlxSound
  _fadeInTimer : Number
FlxSound
  _fadeInTotal : Number
FlxSound
  _fadeOutTimer : Number
FlxSound
  _fadeOutTotal : Number
FlxSound
  _init : Boolean
FlxSound
  _looped : Boolean
FlxSound
  _pan : Boolean
FlxSound
  _pauseOnFadeOut : Boolean
FlxSound
  _point2 : FlxPoint
FlxSound
  _position : Number
FlxSound
  _radius : Number
FlxSound
  _sound : Sound
FlxSound
  _target : FlxObject
FlxSound
  _transform : SoundTransform
FlxSound
  _volume : Number
FlxSound
  _volumeAdjust : Number
FlxSound
Public Methods
 MethodDefined By
  
The FlxSound constructor gets all the variables initialized, but NOT ready to play a sound yet.
FlxSound
  
destroy():void
[override] The basic class destructor, stops the music and removes any leftover events.
FlxSound
 Inherited
draw():void
Override this function to control how the object is drawn.
FlxBasic
  
fadeIn(Seconds:Number):void
Call this function to make a sound fade in over a certain time interval (calls play() automatically).
FlxSound
  
fadeOut(Seconds:Number, PauseInstead:Boolean = false):void
Call this function to make this sound fade out over a certain time interval.
FlxSound
  
FlxSound
 Inherited
kill():void
FlxBasic
  
loadEmbedded(EmbeddedSound:Class, Looped:Boolean = false):FlxSound
One of two main setup functions for sounds, this function loads a sound from an embedded MP3.
FlxSound
  
loadStream(SoundURL:String, Looped:Boolean = false):FlxSound
One of two main setup functions for sounds, this function loads a sound from a URL.
FlxSound
  
onBeat(Callback:Function, Threshold:Number = 0.12, SampleWindow:uint = 5):void
FlxSound
 Inherited
onScreen(Camera:FlxCamera = null):Boolean
FlxBasic
  
pause():void
Call this function to pause this sound.
FlxSound
  
play():void
Call this function to play the sound.
FlxSound
 Inherited
postUpdate():void
FlxBasic
 Inherited
preUpdate():void
FlxBasic
  
proximity(X:Number, Y:Number, Object:FlxObject, Radius:Number, Pan:Boolean = true):FlxSound
Call this function if you want this sound's volume to change based on distance from a particular FlxCore object.
FlxSound
 Inherited
revive():void
FlxBasic
  
stop():void
Call this function to stop this sound.
FlxSound
 Inherited
toString():String
Convert object to readable string name.
FlxBasic
  
update():void
[override] The basic game loop update function.
FlxSound
  
Call after adjusting the volume to update the sound channel's settings.
FlxSound
Protected Methods
 MethodDefined By
  
An internal function for clearing all the variables used by sounds.
FlxSound
  
gotID3(event:Event = null):void
Internal event handler for ID3 info (i.e.
FlxSound
  
looped(event:Event = null):void
An internal helper function used to help Flash resume playing a looped sound.
FlxSound
  
stopped(event:Event = null):void
An internal helper function used to help Flash clean up and re-use finished sounds.
FlxSound
Property Detail
_amplitudeCallbackproperty
protected var _amplitudeCallback:Function

_amplitudeMonitorproperty 
protected var _amplitudeMonitor:FlxMonitor

_amplitudeThresholdproperty 
protected var _amplitudeThreshold:Number

_channelproperty 
protected var _channel:SoundChannel

_fadeInTimerproperty 
protected var _fadeInTimer:Number

_fadeInTotalproperty 
protected var _fadeInTotal:Number

_fadeOutTimerproperty 
protected var _fadeOutTimer:Number

_fadeOutTotalproperty 
protected var _fadeOutTotal:Number

_initproperty 
protected var _init:Boolean

_loopedproperty 
protected var _looped:Boolean

_panproperty 
protected var _pan:Boolean

_pauseOnFadeOutproperty 
protected var _pauseOnFadeOut:Boolean

_point2property 
protected var _point2:FlxPoint

_positionproperty 
protected var _position:Number

_radiusproperty 
protected var _radius:Number

_soundproperty 
protected var _sound:Sound

_targetproperty 
protected var _target:FlxObject

_transformproperty 
protected var _transform:SoundTransform

_volumeproperty 
protected var _volume:Number

_volumeAdjustproperty 
protected var _volumeAdjust:Number

amplitudeproperty 
public var amplitude:Number

Stores the average wave amplitude of both stereo channels

amplitudeLeftproperty 
public var amplitudeLeft:Number

Just the amplitude of the left stereo channel

amplitudeRightproperty 
public var amplitudeRight:Number

Just the amplitude of the left stereo channel

artistproperty 
public var artist:String

The ID3 artist name. Defaults to null. Currently only works for streamed sounds.

nameproperty 
public var name:String

The ID3 song name. Defaults to null. Currently only works for streamed sounds.

surviveproperty 
public var survive:Boolean

Whether or not this sound should be automatically destroyed when you switch states.

volumeproperty 
volume:Number

Set volume to a value between 0 and 1 to change how this sound is.


Implementation
    public function get volume():Number
    public function set volume(value:Number):void
xproperty 
public var x:Number

yproperty 
public var y:Number

Constructor Detail
FlxSound()Constructor
public function FlxSound()

The FlxSound constructor gets all the variables initialized, but NOT ready to play a sound yet.

Method Detail
createSound()method
protected function createSound():void

An internal function for clearing all the variables used by sounds.

destroy()method 
override public function destroy():void

The basic class destructor, stops the music and removes any leftover events.

fadeIn()method 
public function fadeIn(Seconds:Number):void

Call this function to make a sound fade in over a certain time interval (calls play() automatically).

Parameters

Seconds:Number — The amount of time the fade-in operation should take.

fadeOut()method 
public function fadeOut(Seconds:Number, PauseInstead:Boolean = false):void

Call this function to make this sound fade out over a certain time interval.

Parameters

Seconds:Number — The amount of time the fade out operation should take.
 
PauseInstead:Boolean (default = false) — Tells the sound to pause on fadeout, instead of stopping.

getActualVolume()method 
public function getActualVolume():Number

Returns
Number
gotID3()method 
protected function gotID3(event:Event = null):void

Internal event handler for ID3 info (i.e. fetching the song name).

Parameters

event:Event (default = null) — An Event object.

loadEmbedded()method 
public function loadEmbedded(EmbeddedSound:Class, Looped:Boolean = false):FlxSound

One of two main setup functions for sounds, this function loads a sound from an embedded MP3.

Parameters

EmbeddedSound:Class — An embedded Class object representing an MP3 file.
 
Looped:Boolean (default = false) — Whether or not this sound should loop endlessly.

Returns
FlxSound — This FlxSound instance (nice for chaining stuff together, if you're into that).
loadStream()method 
public function loadStream(SoundURL:String, Looped:Boolean = false):FlxSound

One of two main setup functions for sounds, this function loads a sound from a URL.

Parameters

SoundURL:String — A string representing the URL of the MP3 file you want to play.
 
Looped:Boolean (default = false) — Whether or not this sound should loop endlessly.

Returns
FlxSound — This FlxSound instance (nice for chaining stuff together, if you're into that).
looped()method 
protected function looped(event:Event = null):void

An internal helper function used to help Flash resume playing a looped sound.

Parameters

event:Event (default = null) — An Event object.

onBeat()method 
public function onBeat(Callback:Function, Threshold:Number = 0.12, SampleWindow:uint = 5):void

Parameters

Callback:Function
 
Threshold:Number (default = 0.12)
 
SampleWindow:uint (default = 5)

pause()method 
public function pause():void

Call this function to pause this sound.

play()method 
public function play():void

Call this function to play the sound.

proximity()method 
public function proximity(X:Number, Y:Number, Object:FlxObject, Radius:Number, Pan:Boolean = true):FlxSound

Call this function if you want this sound's volume to change based on distance from a particular FlxCore object.

Parameters

X:Number — The X position of the sound.
 
Y:Number — The Y position of the sound.
 
Object:FlxObject — The object you want to track.
 
Radius:Number — The maximum distance this sound can travel.
 
Pan:Boolean (default = true) — Whether the sound should pan in addition to the volume changes (default: true).

Returns
FlxSound — This FlxSound instance (nice for chaining stuff together, if you're into that).
stop()method 
public function stop():void

Call this function to stop this sound.

stopped()method 
protected function stopped(event:Event = null):void

An internal helper function used to help Flash clean up and re-use finished sounds.

Parameters

event:Event (default = null) — An Event object.

update()method 
override public function update():void

The basic game loop update function. Just calls updateSound().

updateTransform()method 
public function updateTransform():void

Call after adjusting the volume to update the sound channel's settings.