| Package | net.flashpunk |
| Class | public class Sfx |
| Inheritance | Sfx Object |
| Property | Defined By | ||
|---|---|---|---|
| complete : Function
Optional callback function for when the sound finishes playing. | Sfx | ||
| length : Number [read-only]
Length of the sound, in seconds. | Sfx | ||
| pan : Number
Alter the panning factor (a value from -1 to 1) of the sound during playback. | Sfx | ||
| playing : Boolean [read-only]
If the sound is currently playing. | Sfx | ||
| position : Number [read-only]
Position of the currently playing sound, in seconds. | Sfx | ||
| type : String
Change the sound type. | Sfx | ||
| volume : Number
Alter the volume factor (a value from 0 to 1) of the sound during playback. | Sfx | ||
| Method | Defined By | ||
|---|---|---|---|
Sfx(source:*, complete:Function = null, type:String = null)
Creates a sound effect from an embedded source. | Sfx | ||
getPan(type:String):Number [static]
Return the global pan for a type. | Sfx | ||
getVolume(type:String):Number [static]
Return the global volume for a type. | Sfx | ||
loop(vol:Number = 1, pan:Number = 0):void
Plays the sound looping. | Sfx | ||
play(vol:Number = 1, pan:Number = 0):void
Plays the sound once. | Sfx | ||
resume():void
Resumes the sound from the position stop() was called on it. | Sfx | ||
setPan(type:String, pan:Number):void [static]
Set the global pan for a type. | Sfx | ||
setVolume(type:String, volume:Number):void [static]
Set the global volume for a type. | Sfx | ||
stop():Boolean
Stops the sound if it is currently playing. | Sfx | ||
| complete | property |
public var complete:FunctionOptional callback function for when the sound finishes playing.
| length | property |
length:Number [read-only] Length of the sound, in seconds.
public function get length():Number| pan | property |
pan:NumberAlter the panning factor (a value from -1 to 1) of the sound during playback.
public function get pan():Number public function set pan(value:Number):void| playing | property |
playing:Boolean [read-only] If the sound is currently playing.
public function get playing():Boolean| position | property |
position:Number [read-only] Position of the currently playing sound, in seconds.
public function get position():Number| type | property |
type:StringChange the sound type. This an arbitrary string you can use to group sounds to mute or pan en masse.
public function get type():String public function set type(value:String):void| volume | property |
volume:NumberAlter the volume factor (a value from 0 to 1) of the sound during playback.
public function get volume():Number public function set volume(value:Number):void| Sfx | () | Constructor |
public function Sfx(source:*, complete:Function = null, type:String = null)Creates a sound effect from an embedded source. Store a reference to this object so that you can play the sound using play() or loop().
Parameterssource:* — The embedded sound class to use or a Sound object.
| |
complete:Function (default = null) — Optional callback function for when the sound finishes playing.
| |
type:String (default = null) |
| getPan | () | method |
public static function getPan(type:String):NumberReturn the global pan for a type.
Parameters
type:String |
Number |
| getVolume | () | method |
public static function getVolume(type:String):NumberReturn the global volume for a type.
Parameters
type:String |
Number |
| loop | () | method |
public function loop(vol:Number = 1, pan:Number = 0):voidPlays the sound looping. Will loop continuously until you call stop(), play(), or loop() again.
Parameters
vol:Number (default = 1) — Volume factor, a value from 0 to 1.
| |
pan:Number (default = 0) — Panning factor, a value from -1 to 1.
|
| play | () | method |
public function play(vol:Number = 1, pan:Number = 0):voidPlays the sound once.
Parameters
vol:Number (default = 1) — Volume factor, a value from 0 to 1.
| |
pan:Number (default = 0) — Panning factor, a value from -1 to 1.
|
| resume | () | method |
public function resume():voidResumes the sound from the position stop() was called on it.
| setPan | () | method |
public static function setPan(type:String, pan:Number):voidSet the global pan for a type. Sfx instances of this type will add this pan to their own.
Parameters
type:String | |
pan:Number |
| setVolume | () | method |
public static function setVolume(type:String, volume:Number):voidSet the global volume for a type. Sfx instances of this type will multiply their volume by this value.
Parameters
type:String | |
volume:Number |
| stop | () | method |
public function stop():BooleanStops the sound if it is currently playing.
ReturnsBoolean —
|