View source

class flaxen.component.Sound implements Completable

Available on all platforms

Basic sound component. Add this to an entity to play a sound file. If this component is removed or the entity is destroyed, the sound will be stopped. The AudioSystem creates a corresponding Audio component for storing the associated OpenFL SoundChannel.

Instance Fields

var complete:Bool

True when sound has completed playing

var failsAllowed:Int

If cannot play sound, tries again the number of times indicated

var file:String

Path to sound file; READ-ONLY

var isMusic:Bool

True if this is an MP3; READ-ONLY

var loop:Bool

Loop sound continuously; if true, you must stop sound manually

var offset:Float

The time from the start of the sound to skip over when playing; READ-ONLY?

var pan:Float

May be modified real-time, will be picked up by AudioSystem

var restart:Bool

Restart sound from beginning ASAP; sets complete to false

var stop:Bool

Stop sound ASAP; sets complete to true

var volume:Float

May be modified real-time, will be picked up by AudioSystem

function new(file:String, ?loop:Bool = false, ?volume:Float = 1, ?pan:Float = 0, ?offset:Float = 0):Void