home *** CD-ROM | disk | FTP | other *** search
- class SoundPlayer
- {
- var channelsAvailable;
- var channel1;
- var channel2;
- var channel3;
- var externalSoundVolume;
- var start;
- function SoundPlayer()
- {
- this.channelsAvailable = new Array(true,true,true);
- this.channel1 = new Sound();
- this.channel2 = new Sound();
- this.channel3 = new Sound();
- this.externalSoundVolume = 100;
- }
- function CleanSounds(intIndex)
- {
- this.channelsAvailable[intIndex] = true;
- }
- function PlaySound(linkIdentifier)
- {
- if(_global.soundOn == true)
- {
- var thisRef = this;
- if(this.channelsAvailable[0] == true)
- {
- this.channelsAvailable[0] = false;
- delete this.channel1;
- this.channel1 = new Sound();
- this.channel1.attachSound(linkIdentifier);
- this.channel1.setVolume(100);
- this.channel1.start(0,0);
- this.channel1.onSoundComplete = function()
- {
- thisRef.CleanSounds(0);
- };
- }
- else if(this.channelsAvailable[1] == true)
- {
- this.channelsAvailable[1] = false;
- delete this.channel2;
- this.channel2 = new Sound();
- this.channel2.attachSound(linkIdentifier);
- this.channel2.setVolume(100);
- this.channel2.start(0,0);
- this.channel2.onSoundComplete = function()
- {
- thisRef.CleanSounds(1);
- };
- }
- else
- {
- this.channelsAvailable[0] = false;
- delete this.channel1;
- this.channel1 = new Sound();
- this.channel1.attachSound(linkIdentifier);
- this.channel1.setVolume(100);
- this.channel1.start(0,0);
- this.channel1.onSoundComplete = function()
- {
- thisRef.CleanSounds(0);
- };
- }
- }
- }
- function PlayBubbleSound(linkIdentifier)
- {
- if(_global.soundOn == true)
- {
- var thisRef = this;
- if(this.channelsAvailable[2] == true)
- {
- this.channelsAvailable[2] = false;
- delete this.channel3;
- this.channel3 = new Sound();
- this.channel3.attachSound(linkIdentifier);
- this.channel3.setVolume(100);
- this.channel3.start(0,0);
- this.channel3.onSoundComplete = function()
- {
- thisRef.CleanSounds(2);
- };
- }
- }
- }
- function PlayExternalSound(urlPath)
- {
- var thisRef = this;
- if(this.channelsAvailable[0] == true)
- {
- this.channelsAvailable[0] = false;
- delete this.channel1;
- this.channel1 = new Sound();
- this.channel1.loadSound(urlPath,false);
- this.channel1.setVolume(this.externalSoundVolume);
- this.channel1.onLoad = function(loadedOK)
- {
- if(loadedOK)
- {
- this.start();
- }
- };
- this.channel1.onSoundComplete = function()
- {
- thisRef.CleanSounds(0);
- };
- }
- else if(this.channelsAvailable[1] == true)
- {
- this.channelsAvailable[1] = false;
- delete this.channel2;
- this.channel2 = new Sound();
- this.channel2.loadSound(urlPath,false);
- this.channel2.setVolume(this.externalSoundVolume);
- this.channel2.onLoad = function(loadedOK)
- {
- if(loadedOK)
- {
- this.start();
- }
- };
- this.channel2.onSoundComplete = function()
- {
- thisRef.CleanSounds(1);
- };
- }
- else
- {
- this.channelsAvailable[0] = false;
- delete this.channel1;
- this.channel1 = new Sound();
- this.channel1.loadSound(urlPath,false);
- this.channel1.setVolume(this.externalSoundVolume);
- this.channel1.onLoad = function(loadedOK)
- {
- if(loadedOK)
- {
- this.start();
- }
- };
- this.channel1.onSoundComplete = function()
- {
- thisRef.CleanSounds(0);
- };
- }
- }
- }
-