home *** CD-ROM | disk | FTP | other *** search
/ Champak 112 / jogo-disk-112.iso / Games / barrels_of_monkey.swf / scripts / __Packages / SoundManager.as < prev   
Text File  |  2010-07-14  |  2KB  |  77 lines

  1. class SoundManager extends Snd
  2. {
  3.    var muted = false;
  4.    var curVol = 100;
  5.    function SoundManager(hld_mc)
  6.    {
  7.       super();
  8.       this.sounds = new Object();
  9.       this.mc_holder = !hld_mc ? _root : hld_mc;
  10.    }
  11.    function playAndRemove(snd_id, offset, loops)
  12.    {
  13.       offset = !isNaN(offset) ? offset : 0;
  14.       loops = !isNaN(loops) ? loops : 0;
  15.       var _loc2_ = this.newSound(snd_id);
  16.       _loc2_.start(offset,loops);
  17.       _loc2_.onSoundComplete = _loc2_.remove;
  18.       return _loc2_;
  19.    }
  20.    function clearAllSounds()
  21.    {
  22.       for(var _loc2_ in this.sounds)
  23.       {
  24.          this.sounds[_loc2_].remove();
  25.       }
  26.    }
  27.    function newSound()
  28.    {
  29.       var _loc5_ = this.mc_holder.getNextHighestDepth();
  30.       var _loc6_ = this.mc_holder.createEmptyMovieClip("sh_mc" + _loc5_,_loc5_);
  31.       var _loc4_ = new Snd(_loc6_,this);
  32.       var _loc3_ = 0;
  33.       while(_loc3_ < arguments.length)
  34.       {
  35.          if(arguments[_loc3_] != undefined)
  36.          {
  37.             _loc4_.attachSound(arguments[_loc3_]);
  38.          }
  39.          _loc3_ = _loc3_ + 1;
  40.       }
  41.       this.sounds[_loc5_] = _loc4_;
  42.       return _loc4_;
  43.    }
  44.    function deleteSound(snd)
  45.    {
  46.       snd.remove();
  47.    }
  48.    function setVolume(vol)
  49.    {
  50.       if(this.muted)
  51.       {
  52.          this.curVol = vol;
  53.       }
  54.       else
  55.       {
  56.          super.setVolume(vol);
  57.       }
  58.    }
  59.    function get mute()
  60.    {
  61.       return this.muted;
  62.    }
  63.    function set mute(b)
  64.    {
  65.       this.muted = b;
  66.       if(b)
  67.       {
  68.          this.curVol = this.getVolume();
  69.          super.setVolume(0);
  70.       }
  71.       else
  72.       {
  73.          super.setVolume(this.curVol);
  74.       }
  75.    }
  76. }
  77.