home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / beauty_resort.swf / scripts / classes / basic / Sound / TFSoundManager.as < prev   
Encoding:
Text File  |  2008-09-04  |  3.0 KB  |  126 lines

  1. package classes.basic.Sound
  2. {
  3.    public class TFSoundManager
  4.    {
  5.       
  6.       private static var MUSIC_VOLUME:Number = 50;
  7.       
  8.       public static var pInstance:TFSoundManager = new TFSoundManager();
  9.       
  10.       private static var SFX_VOLUME:Number = 100;
  11.        
  12.       
  13.       private var arSound:Array;
  14.       
  15.       public function TFSoundManager()
  16.       {
  17.          super();
  18.          arSound = new Array();
  19.       }
  20.       
  21.       public function setMusicVolume(param1:Number) : *
  22.       {
  23.          var _loc2_:TFSound = null;
  24.          var _loc3_:* = undefined;
  25.          if(param1 > 100)
  26.          {
  27.             param1 = 100;
  28.          }
  29.          else if(param1 < 0)
  30.          {
  31.             param1 = 0;
  32.          }
  33.          MUSIC_VOLUME = param1;
  34.          for(_loc3_ in arSound)
  35.          {
  36.             _loc2_ = arSound[_loc3_] as TFSound;
  37.             if(_loc2_.getType() == TFSound.TYPE_MUSIC)
  38.             {
  39.                _loc2_.setVolume(MUSIC_VOLUME);
  40.             }
  41.          }
  42.       }
  43.       
  44.       public function getMusicVolume() : Number
  45.       {
  46.          return MUSIC_VOLUME;
  47.       }
  48.       
  49.       public function removeSound(param1:TFSound) : Boolean
  50.       {
  51.          var _loc2_:Number = NaN;
  52.          _loc2_ = 0;
  53.          while(_loc2_ < arSound.length)
  54.          {
  55.             if(arSound[_loc2_] as TFSound == param1)
  56.             {
  57.                param1.stop();
  58.                arSound.splice(_loc2_,1);
  59.                return true;
  60.             }
  61.             _loc2_++;
  62.          }
  63.          return false;
  64.       }
  65.       
  66.       public function addSound(param1:TFSound) : Boolean
  67.       {
  68.          var _loc2_:* = undefined;
  69.          for(_loc2_ in arSound)
  70.          {
  71.             if(arSound[_loc2_] as TFSound == param1)
  72.             {
  73.                return false;
  74.             }
  75.          }
  76.          arSound.push(param1);
  77.          switch(param1.getType())
  78.          {
  79.             case TFSound.TYPE_MUSIC:
  80.                param1.setVolume(MUSIC_VOLUME);
  81.                break;
  82.             case TFSound.TYPE_SFX:
  83.                param1.setVolume(SFX_VOLUME);
  84.          }
  85.          return true;
  86.       }
  87.       
  88.       public function process(param1:Object) : *
  89.       {
  90.          var _loc2_:* = undefined;
  91.          for(_loc2_ in arSound)
  92.          {
  93.             (arSound[_loc2_] as TFSound).process(param1);
  94.          }
  95.       }
  96.       
  97.       public function getSFXVolume() : Number
  98.       {
  99.          return SFX_VOLUME;
  100.       }
  101.       
  102.       public function setSFXVolume(param1:Number) : *
  103.       {
  104.          var _loc2_:TFSound = null;
  105.          var _loc3_:* = undefined;
  106.          if(param1 > 100)
  107.          {
  108.             param1 = 100;
  109.          }
  110.          else if(param1 < 0)
  111.          {
  112.             param1 = 0;
  113.          }
  114.          SFX_VOLUME = param1;
  115.          for(_loc3_ in arSound)
  116.          {
  117.             _loc2_ = arSound[_loc3_] as TFSound;
  118.             if(_loc2_.getType() == TFSound.TYPE_SFX)
  119.             {
  120.                _loc2_.setVolume(SFX_VOLUME);
  121.             }
  122.          }
  123.       }
  124.    }
  125. }
  126.