| Package | org.flixel |
| Class | public class FlxSound |
| Inheritance | FlxSound FlxBasic Object |
| Property | Defined By | ||
|---|---|---|---|
![]() | active : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup. | FlxBasic | |
![]() | _ACTIVECOUNT : uint [static] | FlxBasic | |
![]() | alive : 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 | ||
| autoDestroy : Boolean
Whether to call destroy() when the sound has finished. | FlxSound | ||
![]() | cameras : Array
An array of camera objects that this object will use during draw(). | FlxBasic | |
![]() | exists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup. | FlxBasic | |
![]() | ID : int
IDs seem like they could be pretty useful, huh?
They're not actually used for anything yet though. | FlxBasic | |
![]() | ignoreDrawDebug : Boolean
Setting this to true will prevent the object from appearing
when the visual debug mode in the debugger overlay is toggled on. | FlxBasic | |
| name : String
The ID3 song name. | FlxSound | ||
| survive : Boolean
Whether or not this sound should be automatically destroyed when you switch states. | FlxSound | ||
![]() | visible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup. | FlxBasic | |
![]() | _VISIBLECOUNT : uint [static] | FlxBasic | |
| volume : Number
Set volume to a value between 0 and 1 to change how this sound is. | FlxSound | ||
| x : Number
The X position of this sound in world coordinates. | FlxSound | ||
| y : Number
The Y position of this sound in world coordinates. | FlxSound | ||
| Property | Defined By | ||
|---|---|---|---|
| _channel : SoundChannel
Internal tracker for a Flash sound channel object. | FlxSound | ||
| _fadeInTimer : Number
Internal timer for fading in the sound playback. | FlxSound | ||
| _fadeInTotal : Number
Internal helper for fading in sounds. | FlxSound | ||
| _fadeOutTimer : Number
Internal timer used to keep track of requests to fade out the sound playback. | FlxSound | ||
| _fadeOutTotal : Number
Internal helper for fading out sounds. | FlxSound | ||
| _looped : Boolean
Internal tracker for whether the sound is looping or not. | FlxSound | ||
| _pan : Boolean
Internal tracker for whether to pan the sound left and right. | FlxSound | ||
| _pauseOnFadeOut : Boolean
Internal flag for whether to pause or stop the sound when it's done fading out. | FlxSound | ||
| _position : Number
Internal tracker for the position in runtime of the music playback. | FlxSound | ||
| _radius : Number
Internal tracker for the maximum effective radius of this sound (for proximity and panning). | FlxSound | ||
| _sound : Sound
Internal tracker for a Flash sound object. | FlxSound | ||
| _target : FlxObject
Internal tracker for the sound's "target" (for proximity and panning). | FlxSound | ||
| _transform : SoundTransform
Internal tracker for a Flash sound transform object. | FlxSound | ||
| _volume : Number
Internal tracker for how loud the sound is. | FlxSound | ||
| _volumeAdjust : Number
Internal tracker for total volume adjustment. | FlxSound | ||
| Method | Defined By | ||
|---|---|---|---|
FlxSound()
The FlxSound constructor gets all the variables initialized, but NOT ready to play a sound yet. | FlxSound | ||
destroy():void [override]
Clean up memory. | FlxSound | ||
![]() | draw():void
Override this function to control how the object is drawn. | FlxBasic | |
![]() |
Override this function to draw custom "debug mode" graphics to the
specified camera while the debugger's visual mode is toggled on. | 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 | ||
getActualVolume():Number
Returns the currently selected "real" volume of the sound (takes fades and proximity into account). | FlxSound | ||
kill():void [override] | FlxSound | ||
loadEmbedded(EmbeddedSound:Class, Looped:Boolean = false, AutoDestroy: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, AutoDestroy:Boolean = false):FlxSound
One of two main setup functions for sounds, this function loads a sound from a URL. | FlxSound | ||
pause():void
Call this function to pause this sound. | FlxSound | ||
play(ForceRestart:Boolean = false):void
Call this function to play the sound - also works on paused sounds. | FlxSound | ||
![]() | postUpdate():void
Post-update is called right after update() on each object in the game loop. | FlxBasic | |
![]() | preUpdate():void
Pre-update is called right before update() on each object in the game loop. | FlxBasic | |
Call this function if you want this sound's volume to change
based on distance from a particular FlxCore object. | FlxSound | ||
resume():void
Unpause a sound. | FlxSound | ||
![]() | revive():void
Handy function for bringing game objects "back to life". | FlxBasic | |
stop():void
Call this function to stop this sound. | FlxSound | ||
![]() | toString():String
Convert object to readable string name. | FlxBasic | |
update():void [override]
Handles fade out, fade in, panning, proximity, and amplitude operations each frame. | FlxSound | ||
updateTransform():void
Call after adjusting the volume to update the sound channel's settings. | FlxSound | ||
| Method | Defined By | ||
|---|---|---|---|
createSound():void
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 | ||
| _channel | property |
protected var _channel:SoundChannelInternal tracker for a Flash sound channel object.
| _fadeInTimer | property |
protected var _fadeInTimer:NumberInternal timer for fading in the sound playback.
| _fadeInTotal | property |
protected var _fadeInTotal:NumberInternal helper for fading in sounds.
| _fadeOutTimer | property |
protected var _fadeOutTimer:NumberInternal timer used to keep track of requests to fade out the sound playback.
| _fadeOutTotal | property |
protected var _fadeOutTotal:NumberInternal helper for fading out sounds.
| _looped | property |
protected var _looped:BooleanInternal tracker for whether the sound is looping or not.
| _pan | property |
protected var _pan:BooleanInternal tracker for whether to pan the sound left and right. Default is false.
| _pauseOnFadeOut | property |
protected var _pauseOnFadeOut:BooleanInternal flag for whether to pause or stop the sound when it's done fading out.
| _position | property |
protected var _position:NumberInternal tracker for the position in runtime of the music playback.
| _radius | property |
protected var _radius:NumberInternal tracker for the maximum effective radius of this sound (for proximity and panning).
| _sound | property |
protected var _sound:SoundInternal tracker for a Flash sound object.
| _target | property |
protected var _target:FlxObjectInternal tracker for the sound's "target" (for proximity and panning).
| _transform | property |
protected var _transform:SoundTransformInternal tracker for a Flash sound transform object.
| _volume | property |
protected var _volume:NumberInternal tracker for how loud the sound is.
| _volumeAdjust | property |
protected var _volumeAdjust:NumberInternal tracker for total volume adjustment.
| amplitude | property |
public var amplitude:NumberStores the average wave amplitude of both stereo channels
| amplitudeLeft | property |
public var amplitudeLeft:NumberJust the amplitude of the left stereo channel
| amplitudeRight | property |
public var amplitudeRight:NumberJust the amplitude of the left stereo channel
| artist | property |
public var artist:StringThe ID3 artist name. Defaults to null. Currently only works for streamed sounds.
| autoDestroy | property |
public var autoDestroy:BooleanWhether to call destroy() when the sound has finished.
| name | property |
public var name:StringThe ID3 song name. Defaults to null. Currently only works for streamed sounds.
| survive | property |
public var survive:BooleanWhether or not this sound should be automatically destroyed when you switch states.
| volume | property |
volume:Number
Set volume to a value between 0 and 1 to change how this sound is.
public function get volume():Number public function set volume(value:Number):void| x | property |
public var x:NumberThe X position of this sound in world coordinates. Only really matters if you are doing proximity/panning stuff.
| y | property |
public var y:NumberThe Y position of this sound in world coordinates. Only really matters if you are doing proximity/panning stuff.
| FlxSound | () | Constructor |
public function FlxSound()The FlxSound constructor gets all the variables initialized, but NOT ready to play a sound yet.
| createSound | () | method |
protected function createSound():voidAn internal function for clearing all the variables used by sounds.
| destroy | () | method |
override public function destroy():voidClean up memory.
| 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):voidCall 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():NumberReturns the currently selected "real" volume of the sound (takes fades and proximity into account).
ReturnsNumber — The adjusted volume of the sound.
|
| gotID3 | () | method |
protected function gotID3(event:Event = null):voidInternal event handler for ID3 info (i.e. fetching the song name).
Parameters
event:Event (default = null) — An Event object.
|
| kill | () | method |
override public function kill():void| loadEmbedded | () | method |
public function loadEmbedded(EmbeddedSound:Class, Looped:Boolean = false, AutoDestroy:Boolean = false):FlxSoundOne 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.
| |
AutoDestroy:Boolean (default = false) — Whether or not this FlxSound instance should be destroyed when the sound finishes playing. Default value is false, but FlxG.play() and FlxG.stream() will set it to true by default.
|
FlxSound — This FlxSound instance (nice for chaining stuff together, if you're into that).
|
| loadStream | () | method |
public function loadStream(SoundURL:String, Looped:Boolean = false, AutoDestroy:Boolean = false):FlxSoundOne 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.
| |
AutoDestroy:Boolean (default = false) — Whether or not this FlxSound instance should be destroyed when the sound finishes playing. Default value is false, but FlxG.play() and FlxG.stream() will set it to true by default.
|
FlxSound — This FlxSound instance (nice for chaining stuff together, if you're into that).
|
| looped | () | method |
protected function looped(event:Event = null):voidAn internal helper function used to help Flash resume playing a looped sound.
Parameters
event:Event (default = null) — An Event object.
|
| pause | () | method |
public function pause():voidCall this function to pause this sound.
| play | () | method |
public function play(ForceRestart:Boolean = false):voidCall this function to play the sound - also works on paused sounds.
Parameters
ForceRestart:Boolean (default = false) — Whether to start the sound over or not. Default value is false, meaning if the sound is already playing or was paused when you call play(), it will continue playing from its current position, NOT start again from the beginning.
|
| proximity | () | method |
public function proximity(X:Number, Y:Number, Object:FlxObject, Radius:Number, Pan:Boolean = true):FlxSoundCall 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).
|
FlxSound — This FlxSound instance (nice for chaining stuff together, if you're into that).
|
| resume | () | method |
public function resume():voidUnpause a sound. Only works on sounds that have been paused.
| stop | () | method |
public function stop():voidCall this function to stop this sound.
| stopped | () | method |
protected function stopped(event:Event = null):voidAn 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():voidHandles fade out, fade in, panning, proximity, and amplitude operations each frame.
| updateTransform | () | method |
public function updateTransform():voidCall after adjusting the volume to update the sound channel's settings.