Packageorg.flixel
Classpublic class FlxSound
InheritanceFlxSound Inheritance FlxObject Inheritance FlxRect Inheritance FlxPoint

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



Public Properties
 PropertyDefined by
 Inheritedacceleration : FlxPoint
How fast the speed of this object is changing.
FlxObject
 Inheritedactive : Boolean
If an object is not alive, the game loop will not automatically call update() on it.
FlxObject
 Inheritedangle : Number
Set the angle of a sprite to rotate it.
FlxObject
 InheritedangularAcceleration : Number
How fast the spin speed should change.
FlxObject
 InheritedangularDrag : Number
Like drag but for spinning.
FlxObject
 InheritedangularVelocity : Number
This is how fast you want this sprite to spin.
FlxObject
  artist : String
The ID3 artist name.
FlxSound
 Inheritedbottom : Number
The Y coordinate of the bottom of the rectangle.
FlxRect
 InheritedcolHullX : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
FlxObject
 InheritedcolHullY : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
FlxObject
 InheritedcollideBottom : Boolean
Flag for direction collision resolution.
FlxObject
 InheritedcollideLeft : Boolean
Flag for direction collision resolution.
FlxObject
 InheritedcollideRight : Boolean
Flag for direction collision resolution.
FlxObject
 InheritedcollideTop : Boolean
Flag for direction collision resolution.
FlxObject
 InheritedcolOffsets : Array
An array of FlxPoint objects.
FlxObject
 InheritedcolVector : FlxPoint
These store a couple of useful numbers for speeding up collision resolution.
FlxObject
 Inheriteddead : Boolean
Handy for tracking gameplay or animations.
FlxObject
 Inheriteddrag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.
FlxObject
 Inheritedexists : Boolean
Kind of a global on/off switch for any objects descended from FlxObject.
FlxObject
 Inheritedfixed : Boolean
Set fixed to true if you want the object to stay in place during collisions.
FlxObject
 Inherited_group : Boolean
Dedicated internal flag for whether or not this class is a FlxGroup.
FlxObject
 Inheritedhealth : Number
Handy for storing health percentage or armor points or whatever.
FlxObject
 Inheritedheight : Number
FlxRect
 Inheritedleft : Number
The X coordinate of the left side of the rectangle.
FlxRect
 InheritedmaxAngular : Number
Use in conjunction with angularAcceleration for fluid spin speed control.
FlxObject
 InheritedmaxThrust : Number
Used to cap thrust, helpful and easy!
FlxObject
 InheritedmaxVelocity : FlxPoint
If you are using acceleration, you can use maxVelocity with it to cap the speed automatically (very useful!).
FlxObject
 Inheritedmoves : Boolean
Set this to false if you want to skip the automatic motion/movement stuff (see updateMotion()).
FlxObject
  name : String
The ID3 song name.
FlxSound
 InheritedonFloor : Boolean
Flag that indicates whether or not you just hit the floor.
FlxObject
 Inheritedorigin : FlxPoint
WARNING: The origin of the sprite will default to its center.
FlxObject
  playing : Boolean
Whether the sound is currently playing or not.
FlxSound
 Inheritedright : Number
The X coordinate of the right side of the rectangle.
FlxRect
 InheritedscrollFactor : FlxPoint
A point that can store numbers from 0 to 1 (for X and Y independently) that governs how much this object is affected by the camera subsystem.
FlxObject
 Inheritedsolid : Boolean
Set solid to true if you want to collide this object.
FlxObject
  survive : Boolean
Whether or not this sound should be automatically destroyed when you switch states.
FlxSound
 Inheritedthrust : Number
If you want to do Asteroids style stuff, check out thrust, instead of directly accessing the object's velocity or acceleration.
FlxObject
 Inheritedtop : Number
The Y coordinate of the top of the rectangle.
FlxRect
 Inheritedvelocity : FlxPoint
The basic speed of this object.
FlxObject
 Inheritedvisible : Boolean
If an object is not visible, the game loop will not automatically call render() on it.
FlxObject
  volume : Number
Set volume to a value between 0 and 1 to change how this sound is.
FlxSound
 Inheritedwidth : Number
FlxRect
 Inheritedx : Number
FlxPoint
 Inheritedy : Number
FlxPoint
Protected Properties
 PropertyDefined by
  _channel : SoundChannel
FlxSound
  _core : FlxObject
FlxSound
  _fadeInTimer : Number
FlxSound
  _fadeInTotal : Number
FlxSound
  _fadeOutTimer : Number
FlxSound
  _fadeOutTotal : Number
FlxSound
 Inherited_fixed : Boolean
Internal tracker for whether an object will move/alter position after a collision (see fixed).
FlxObject
 Inherited_flashPoint : Point
This is a pre-allocated Flash Point object, which is useful for certain Flash graphics API calls
FlxObject
 Inherited_flicker : Boolean
Internal helper used for retro-style flickering.
FlxObject
 Inherited_flickerTimer : Number
Internal helper used for retro-style flickering.
FlxObject
  _init : Boolean
FlxSound
  _looped : Boolean
FlxSound
  _pan : Boolean
FlxSound
  _pauseOnFadeOut : Boolean
FlxSound
 Inherited_point : FlxPoint
This is just a pre-allocated x-y point container to be used however you like
FlxObject
  _point2 : FlxPoint
FlxSound
  _position : Number
FlxSound
  _radius : Number
FlxSound
 Inherited_rect : FlxRect
This is just a pre-allocated rectangle container to be used however you like
FlxObject
 Inherited_solid : Boolean
Internal tracker for whether or not the object collides (see solid).
FlxObject
  _sound : Sound
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
 Inherited
collide(Object:FlxObject = null):Boolean
If you don't want to call FlxU.collide() you can use this instead.
FlxObject
  
destroy():void
The basic class destructor, stops the music and removes any leftover events.
FlxSound
  
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
 Inherited
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
FlxObject
 Inherited
flickering():Boolean
Check to see if the object is still flickering.
FlxObject
 Inherited
Returns the appropriate color for the bounding box depending on object state.
FlxObject
 Inherited
getScreenXY(Point:FlxPoint = null):FlxPoint
Call this function to figure out the on-screen position of the object.
FlxObject
 Inherited
hitBottom(Contact:FlxObject, Velocity:Number):void
Called when this object's bottom edge collides with the top of another FlxObject.
FlxObject
 Inherited
hitLeft(Contact:FlxObject, Velocity:Number):void
Called when this object's left side collides with another FlxObject's right.
FlxObject
 Inherited
hitRight(Contact:FlxObject, Velocity:Number):void
Called when this object's right side collides with another FlxObject's left.
FlxObject
 Inherited
hitSide(Contact:FlxObject, Velocity:Number):void
Since most games have identical behavior for running into walls, you can just override this function instead of overriding both hitLeft and hitRight.
FlxObject
 Inherited
hitTop(Contact:FlxObject, Velocity:Number):void
Called when this object's top collides with the bottom of another FlxObject.
FlxObject
 Inherited
hurt(Damage:Number):void
Call this function to "damage" (or give health bonus) to this sprite.
FlxObject
 Inherited
kill():void
Call this function to "kill" a sprite so that it no longer 'exists'.
FlxObject
  
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
 Inherited
onScreen():Boolean
Check and see if this object is currently on screen.
FlxObject
 Inherited
overlaps(Object:FlxObject):Boolean
Checks to see if some FlxObject object overlaps this FlxObject object.
FlxObject
 Inherited
overlapsPoint(X:Number, Y:Number, PerPixel:Boolean = false):Boolean
Checks to see if a point in 2D space overlaps this FlxObject object.
FlxObject
  
pause():void
Call this function to pause this sound.
FlxSound
  
play():void
Call this function to play the sound.
FlxSound
 Inherited
preCollide(Object:FlxObject):void
FlxU.collide() (and thus FlxObject.collide()) call this function each time two objects are compared to see if they collide.
FlxObject
  
proximity(X:Number, Y:Number, Core: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
refreshHulls():void
Called by FlxObject.updateMotion() and some constructors to rebuild the basic collision data for this object.
FlxObject
 Inherited
render():void
Override this function to draw graphics (see FlxSprite).
FlxObject
 Inherited
reset(X:Number, Y:Number):void
Handy function for reviving game objects.
FlxObject
  
stop():void
Call this function to stop this sound.
FlxSound
 Inherited
toString():String
Convert object to readable string name.
FlxPoint
  
update():void
The basic game loop update function.
FlxSound
  
An internal function used to help organize and change the volume of the sound.
FlxSound
Protected Methods
 MethodDefined by
  
gotID3(event:Event = null):void
Internal event handler for ID3 info (i.e.
FlxSound
  
init():void
An internal function for clearing all the variables used by sounds.
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
 Inherited
Just updates the retro-style flickering.
FlxObject
 Inherited
updateMotion():void
Internal function for updating the position and speed of this object.
FlxObject
  
updateSound():void
Internal function that performs the actual logical updates to the sound object.
FlxSound
Protected Constants
 ConstantDefined by
 Inherited_pZero : FlxPoint
[static] A handy "empty point" object
FlxObject
Property detail
artistproperty
public var artist:String

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

_channelproperty 
protected var _channel:SoundChannel
_coreproperty 
protected var _core:FlxObject
_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
nameproperty 
public var name:String

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

_panproperty 
protected var _pan:Boolean
_pauseOnFadeOutproperty 
protected var _pauseOnFadeOut:Boolean
playingproperty 
public var playing:Boolean

Whether the sound is currently playing or not.

_point2property 
protected var _point2:FlxPoint
_positionproperty 
protected var _position:Number
_radiusproperty 
protected var _radius:Number
_soundproperty 
protected var _sound:Sound
surviveproperty 
public var survive:Boolean

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

_transformproperty 
protected var _transform:SoundTransform
_volumeproperty 
protected var _volume:Number
volumeproperty 
volume:Number  [read-write]

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
_volumeAdjustproperty 
protected var _volumeAdjust: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
destroy()method
public override 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.
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.
init()method 
protected function init():void

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

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.
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, Core: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.
 
Core:FlxObject — The object you want to track.
 
Radius:Number — The maximum distance this sound can travel.
 
Pan:Boolean (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 
public override function update():void

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

updateSound()method 
protected function updateSound():void

Internal function that performs the actual logical updates to the sound object. Doesn't do much except optional proximity and fade calculations.

updateTransform()method 
public function updateTransform():void

An internal function used to help organize and change the volume of the sound.