home *** CD-ROM | disk | FTP | other *** search
- class SoundPlayer
- {
- var channelsAvailable;
- var channel1;
- var channel2;
- var channel3;
- var channel4;
- var channel5;
- var channel6;
- var channel7;
- var externalSoundVolume;
- var start;
- function SoundPlayer()
- {
- this.channelsAvailable = new Array(true,true,true,true,true,true,true);
- this.channel1 = new Sound(_root.soundOneClip);
- this.channel2 = new Sound(_root.soundTwoClip);
- this.channel3 = new Sound(_root.soundThreeClip);
- this.channel4 = new Sound(_root.soundFourClip);
- this.channel5 = new Sound(_root.soundFiveClip);
- this.channel6 = new Sound(_root.soundSixClip);
- this.channel7 = new Sound(_root.soundSevenClip);
- 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(_root.soundOneClip);
- 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(_root.soundTwoClip);
- this.channel2.attachSound(linkIdentifier);
- this.channel2.setVolume(100);
- this.channel2.start(0,0);
- this.channel2.onSoundComplete = function()
- {
- thisRef.CleanSounds(1);
- };
- }
- else if(this.channelsAvailable[4] == true)
- {
- this.channelsAvailable[4] = false;
- delete this.channel5;
- this.channel5 = new Sound(_root.soundFiveClip);
- this.channel5.attachSound(linkIdentifier);
- this.channel5.setVolume(100);
- this.channel5.start(0,0);
- this.channel5.onSoundComplete = function()
- {
- thisRef.CleanSounds(4);
- };
- }
- else if(this.channelsAvailable[5] == true)
- {
- this.channelsAvailable[5] = false;
- delete this.channel6;
- this.channel6 = new Sound(_root.soundSixClip);
- this.channel6.attachSound(linkIdentifier);
- this.channel6.setVolume(100);
- this.channel6.start(0,0);
- this.channel6.onSoundComplete = function()
- {
- thisRef.CleanSounds(5);
- };
- }
- else
- {
- this.channelsAvailable[0] = false;
- delete this.channel1;
- this.channel1 = new Sound(_root.soundOneClip);
- 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(_root.soundThreeClip);
- this.channel3.attachSound(linkIdentifier);
- this.channel3.setVolume(100);
- this.channel3.start(0,0);
- this.channel3.onSoundComplete = function()
- {
- thisRef.CleanSounds(2);
- };
- }
- else if(this.channelsAvailable[3] == true)
- {
- this.channelsAvailable[3] = false;
- delete this.channel4;
- this.channel4 = new Sound(_root.soundFourClip);
- this.channel4.attachSound(linkIdentifier);
- this.channel4.setVolume(80);
- this.channel4.start(0,0);
- this.channel4.onSoundComplete = function()
- {
- thisRef.CleanSounds(3);
- };
- }
- else if(this.channelsAvailable[6] == true)
- {
- this.channelsAvailable[6] = false;
- delete this.channel7;
- this.channel7 = new Sound(_root.soundSevenClip);
- this.channel7.attachSound(linkIdentifier);
- this.channel7.setVolume(60);
- this.channel7.start(0,0);
- this.channel7.onSoundComplete = function()
- {
- thisRef.CleanSounds(6);
- };
- }
- }
- }
- 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);
- };
- }
- }
- }
-