class flixel.system.FlxSound extends FlxBasic
Available on all platforms
This is the universal flixel sound object, used for streaming, music, and sound effects.
Instance Fields
The X position of this sound in world coordinates. * Only really matters if you are doing proximity/panning stuff.
The Y position of this sound in world coordinates. * Only really matters if you are doing proximity/panning stuff.
function fadeIn(?Duration:Float = 1, ?From:Float = 0, ?To:Float = 1):FlxSound
Helper function that tweens this sound's volume. * *
Duration | The amount of time the fade-in operation should take. * |
From | The volume to tween from, 0 by default. * |
To | The volume to tween to, 1 by default. |
function fadeOut(?Duration:Float = 1, ?To:Float = 0):FlxSound
Helper function that tweens this sound's volume. * *
Duration | The amount of time the fade-out operation should take. * |
To | The volume to tween to, 0 by default. |
function getActualVolume():Float
Returns the currently selected "real" volume of the sound (takes fades and proximity into account). * *
returns | The adjusted volume of the sound. |
function loadByteArray(Bytes:ByteArray, ?Looped:Bool = false, ?AutoDestroy:Bool = false, ?OnComplete:Void ->Void = null):FlxSound
One of the main setup functions for sounds, this function loads a sound from a ByteArray. * *
Bytes | A ByteArray object. * |
Looped | Whether or not this sound should loop endlessly. * |
AutoDestroy | Whether or not this FlxSound instance should be destroyed when the sound finishes playing. Default value is false, but FlxG.sound.play() and FlxG.sound.stream() will set it to true by default. * |
returns | This FlxSound instance (nice for chaining stuff together, if you're into that). |
function loadEmbedded(EmbeddedSound:Dynamic, ?Looped:Bool = false, ?AutoDestroy:Bool = false, ?OnComplete:Void ->Void = null):FlxSound
One of two main setup functions for sounds, this function loads a sound from an embedded MP3. * *
EmbeddedSound | An embedded Class object representing an MP3 file. * |
Looped | Whether or not this sound should loop endlessly. * |
AutoDestroy | Whether or not this FlxSound instance should be destroyed when the sound finishes playing. Default value is false, but FlxG.sound.play() and FlxG.sound.stream() will set it to true by default. * * |
returns | This FlxSound instance (nice for chaining stuff together, if you're into that). |
function loadStream(SoundURL:String, ?Looped:Bool = false, ?AutoDestroy:Bool = false, ?OnComplete:Void ->Void = null):FlxSound
One of two main setup functions for sounds, this function loads a sound from a URL. * *
EmbeddedSound | A string representing the URL of the MP3 file you want to play. * |
Looped | Whether or not this sound should loop endlessly. * |
AutoDestroy | Whether or not this FlxSound instance should be destroyed when the sound finishes playing. Default value is false, but FlxG.sound.play() and FlxG.sound.stream() will set it to true by default. * * |
returns | This FlxSound instance (nice for chaining stuff together, if you're into that). |
function onComplete():Void
Tracker for sound complete callback. Default is null. If assigend, will be called * each time when sound reaches its end. Works only on flash and desktop targets.
function play(?ForceRestart:Bool = false):FlxSound
Call this function to play the sound - also works on paused sounds. * *
ForceRestart | 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. |
function proximity(X:Float, Y:Float, TargetObject:FlxObject, Radius:Float, ?Pan:Bool = true):FlxSound
Call this function if you want this sound's volume to change * based on distance from a particular FlxObject. * *
X | The X position of the sound. * |
Y | The Y position of the sound. * |
TargetObject | The object you want to track. * |
Radius | The maximum distance this sound can travel. * |
Pan | Whether panning should be used in addition to the volume changes (default: true). * |
returns | This FlxSound instance (nice for chaining stuff together, if you're into that). |
function setPosition(?X:Float = 0, ?Y:Float = 0):Void
Helper function to set the coordinates of this object. * Sound positioning is used in conjunction with proximity/panning. * *
X | The new x position * |
Y | The new y position |