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; // this would be whatever class instantiates your game.
- [Embed(source = "../Sounds/GunshotSelect.mp3")]
- protected static const gunShotClass:Class;
- var gunShotSound:Sound = new gunShotClass;
- /*[Embed(source = "../Music/MusicLoop.mp3")]
- protected static const mainMusicClass:Class;
- var mainMusicLoop:Sound = new mainMusicClass;
- */
- var musicChannel:SoundChannel; // not used for sound effects, ignore it for now
- public function SoundManager(mClass) {
- // constructor code
- mainClass = mClass
- }
- /*
- function startMusic(){
- if(musicChannel != null){
- musicChannel.stop();
- }
- musicChannel = mainMusicLoop.play();
- musicChannel.addEventListener(Event.SOUND_COMPLETE,loopMusic)
- }
- function loopMusic(e:Event){
- startMusic();
- }
- */
- function playSound(soundName:String){
- switch(soundName){
- case "gunshot":
- gunShotSound.play();
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement