Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.media.SoundChannel;
- import flash.media.Sound;
- import flash.events.Event;
- public class SoundManager {
- var mainClass:Main;
- var battleLoop:Sound = new BattleLoop1();
- var blockDamage:Sound = new BlockDamage();
- var blockCrumble:Sound = new BlockCrumble();
- var blockRebound:Sound = new BlockRebound();
- var ballBounce:Sound = new BallBounce();
- var explosion1:Sound = new Explosion1();
- var explosion2:Sound = new Explosion2();
- var explosion3:Sound = new Explosion3();
- var explosion4:Sound = new Explosion4();
- var explosion5:Sound = new Explosion5();
- var laser1:Sound = new Laser1();
- var laser2:Sound = new Laser2();
- var powerup1:Sound = new Powerup1();
- var powerup2:Sound = new Powerup2();
- var powerup3:Sound = new Powerup3();
- var powerup4:Sound = new Powerup4();
- var powerup5:Sound = new Powerup5();
- var powerup6:Sound = new Powerup6();
- var musicChannel:SoundChannel;
- var victoryChannel:SoundChannel;
- public function SoundManager(mClass) {
- // constructor code
- mainClass = mClass
- }
- function startBattleMusic(){
- if(musicChannel != null){
- musicChannel.stop();
- }
- musicChannel = battleLoop.play();
- musicChannel.addEventListener(Event.SOUND_COMPLETE,loopBattleMusic)
- }
- function loopBattleMusic(e:Event){
- startBattleMusic();
- }
- function finishBattle(){
- musicChannel.stop();
- victoryChannel = victoryJingle.play();
- victoryChannel.addEventListener(Event.SOUND_COMPLETE,finishJingle)
- }
- function finishJingle(e:Event){
- trace("jingle finished")
- }
- function playSound(soundName:String){
- if(soundName == "blockDamage"){
- blockDamage.play();
- }
- else if(soundName == "blockCrumble"){
- blockCrumble.play();
- }
- else if(soundName == "metalCollide"){
- blockRebound.play();
- }
- else if(soundName == "laserShot1"){
- laser1.play();
- }
- else if(soundName == "laserShot2"){
- laser2.play();
- }
- else if(soundName == "paddleBounce"){
- ballBounce.play();
- }
- else if(soundName == "ballBounce"){
- ballBounce.play();
- }
- else if(soundName == "powerup1"){
- powerup1.play();
- }
- else if(soundName == "powerup2"){
- powerup2.play();
- }
- else if(soundName == "powerup3"){
- powerup3.play();
- }
- else if(soundName == "powerup4"){
- powerup4.play();
- }
- else if(soundName == "powerup5"){
- powerup5.play();
- }
- else if(soundName == "powerup6"){
- powerup6.play();
- }
- else if(soundName == "ballExplode"){
- explosion5.play();
- }
- else if(soundName == "explosion1"){
- explosion1.play();
- }
- else if(soundName == "explosion2"){
- explosion2.play();
- }
- else if(soundName == "explosion3"){
- explosion3.play();
- }
- else if(soundName == "explosion4"){
- explosion4.play();
- }
- else if(soundName == "explosion5"){
- explosion5.play();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement