home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / kung_fu.swf / scripts / __Packages / ds / controls / SoundPlayer.as next >
Encoding:
Text File  |  2006-06-13  |  2.4 KB  |  85 lines

  1. class ds.controls.SoundPlayer
  2. {
  3.    var start;
  4.    static var holder = _root.createEmptyMovieClip("_soundholder",_root.getNextHighestDepth());
  5.    static var isMute = false;
  6.    function SoundPlayer()
  7.    {
  8.    }
  9.    static function playSound(name_str, type)
  10.    {
  11.       if(ds.controls.SoundPlayer.isMute)
  12.       {
  13.          return undefined;
  14.       }
  15.       if(typeof ds.controls.SoundPlayer.holder[name_str] != "movieclip")
  16.       {
  17.          var _loc2_ = ds.controls.SoundPlayer.holder.createEmptyMovieClip(name_str,ds.controls.SoundPlayer.holder.getNextHighestDepth());
  18.          _loc2_._sound = new Sound(_loc2_);
  19.          _loc2_._sound.attachSound(name_str);
  20.          _loc2_._linkage = name_str;
  21.          if(type == "loop")
  22.          {
  23.             _loc2_._type = "loop";
  24.             _loc2_._sound.onSoundComplete = function()
  25.             {
  26.                this.start();
  27.             };
  28.          }
  29.          else
  30.          {
  31.             ds.controls.SoundPlayer.holder[name_str]._type = "effect";
  32.          }
  33.       }
  34.       if(ds.controls.SoundPlayer.holder[name_str]._type == "loop")
  35.       {
  36.          ds.controls.SoundPlayer.holder[name_str]._sound.start(0,999999);
  37.       }
  38.       else
  39.       {
  40.          ds.controls.SoundPlayer.holder[name_str]._sound.start();
  41.       }
  42.    }
  43.    static function stopSound(name_str)
  44.    {
  45.       if(typeof ds.controls.SoundPlayer.holder[name_str] == "movieclip")
  46.       {
  47.          ds.controls.SoundPlayer.holder[name_str]._sound.stop();
  48.       }
  49.    }
  50.    static function stopAll()
  51.    {
  52.       for(var _loc1_ in ds.controls.SoundPlayer.holder)
  53.       {
  54.          ds.controls.SoundPlayer.holder[_loc1_]._sound.stop();
  55.       }
  56.    }
  57.    static function playAll()
  58.    {
  59.       if(ds.controls.SoundPlayer.isMute)
  60.       {
  61.          return undefined;
  62.       }
  63.       for(var _loc1_ in ds.controls.SoundPlayer.holder)
  64.       {
  65.          ds.controls.SoundPlayer.holder[_loc1_]._sound.start();
  66.       }
  67.    }
  68.    static function mute()
  69.    {
  70.       ds.controls.SoundPlayer.isMute = true;
  71.       ds.controls.SoundPlayer.stopAll();
  72.    }
  73.    static function unmute()
  74.    {
  75.       ds.controls.SoundPlayer.isMute = false;
  76.       for(var _loc1_ in ds.controls.SoundPlayer.holder)
  77.       {
  78.          if(ds.controls.SoundPlayer.holder[_loc1_]._type == "loop")
  79.          {
  80.             ds.controls.SoundPlayer.holder[_loc1_]._sound.start();
  81.          }
  82.       }
  83.    }
  84. }
  85.