package ui
{
   import flash.media.SoundChannel;
   import flash.media.Sound;
   import sound.BgSound;
   import sound.FlySound;
   
   public class GameSound extends Object
   {
      
      public function GameSound()
      {
         this.bgSound = new BgSound();
         this.flySound = new FlySound();
         super();
      }
      
      private var bgSoundChannel:SoundChannel;
      
      private var bgSound:Sound;
      
      public function playBGSound() : void
      {
         if(this.bgSoundChannel == null)
         {
            this.bgSoundChannel = this.bgSound.play(0,int.MAX_VALUE);
         }
      }
      
      public function stopBGSound() : void
      {
         if(this.bgSoundChannel != null)
         {
            this.bgSoundChannel.stop();
            this.bgSoundChannel = null;
         }
      }
      
      private var flySoundChannel:SoundChannel;
      
      private var flySound:Sound;
      
      public function playFlySound() : void
      {
         if(this.flySoundChannel == null)
         {
            this.flySoundChannel = this.flySound.play(0,int.MAX_VALUE);
         }
      }
      
      public function stopFlySound() : void
      {
         if(this.flySoundChannel != null)
         {
            this.flySoundChannel.stop();
            this.flySoundChannel = null;
         }
      }
   }
}
