MixSoundFactory

Kind of class:class
Inherits from:SoundFactory
Version:1.0
Author:Francis Bourre
Classpath:com.bourre.medias.sound.MixSoundFactory
File last modified:Wednesday, 31 October 2007, 07:35:29
MixSoundFactory extends SoundFactory class adding volume, pan and gain
controls for sound.

Example

function onSoundComplete( e : IEvent ) : Void {
  trace("play again");
}

var sf : MixSoundFactory = new MixSoundFactory();
sf.addEventListener( MixSoundFactory.onSoundCompleteEVENT, this);
sf.addSound("sound_1");
sf.setGain("sound_1", 50);
sf.setPan(-50);

sf.playSoundLoop("sound_1");

Constructor

MixSoundFactory

function MixSoundFactory (
)
Constructs a new MixSoundFactory instance.

Class properties

onSoundCompleteEVENT

static onSoundCompleteEVENT:EventType = new EventType("onSoundComplete")
(read,write)
Broadcast when a sound finishes playing.
Component metadata:
Event
onSoundLoad

Instance methods

addSound

function addSound (
linkageID:String) : String
Adds new sound to factory.

Overrides SoundFactory.removeSound method, adding
sID sound in gain list.

Example

var sf : MixSoundFactory = new MixSoundFactory();
sf.addSound("sound_1");
sf.addSound("sound_2");
Parameters:
linkageID:
Sound identifier in swf file
Returns:
String sound identifier

getGain

function getGain (
sID:String) : Number
Returns defined gain for passed-in sID sound id.
Parameters:
sID:
Sound id.
Returns:
Number value

getPan

function getPan (
) : Number
Returns pan value.
Returns:
Number value

getVolume

function getVolume (
) : Number
Returns volume value.
Returns:
Number value

playSoundLoop

function playSoundLoop (
sID:String) : Void
Plays passed-in sID identifier sound in loop mode.

Overrides SoundFactory.playSoundLoop method adding event support when sound
finishes playing.
MixSoundFactory broadcast onSoundCompleteEVENT

Example

function onSoundComplete( e : IEvent ) : Void {
  trace("play again");
}

var sf : MixSoundFactory = new MixSoundFactory();
sf.addSound("sound_1");
sf.addEventListener( MixSoundFactory.onSoundCompleteEVENT, this);
sf.playSoundLoop("sound_1");

removeSound

function removeSound (
sID:String) : Void
Removes Sound instance stored under passed-in
sID identifier from factory.

Overrides SoundFactory.removeSound method, removing
sID sound from gain list.

Example

var sf : MixSoundFactory = new MixSoundFactory();
sf.addSound("sound_1");
sf.removeSound("sound_1");

setAllGain

function setAllGain (
nGain:Number) : Void
Defines gain value for all stored sounds.

nGain should be between 0 and 127.

Parameters:
nGain:
Number value

setGain

function setGain (
sID:String, nGain:Number) : Void
Defines gain value for passed-in sID sound.

nGain should be between 0 and 127.

Parameters:
sID :
Sound id stored in factory
nGain:
Number value

setPan

function setPan (
n:Number) : Void
Defines pan value for all sounds list.

n should be between -100 and 100.

Parameters:
n:
Number value

setVolume

function setVolume (
n:Number) : Void
Defines volume value for all sounds list.

n should be between 0 and 100.

Parameters:
n:
Number value

toString

function toString (
) : String
Returns the string representation of this instance.
Returns:
the string representation of this instance