home *** CD-ROM | disk | FTP | other *** search
- package classes.basic.Sound
- {
- public class TFSoundManager
- {
-
- private static var MUSIC_VOLUME:Number = 50;
-
- public static var pInstance:TFSoundManager = new TFSoundManager();
-
- private static var SFX_VOLUME:Number = 100;
-
-
- private var arSound:Array;
-
- public function TFSoundManager()
- {
- super();
- arSound = new Array();
- }
-
- public function setMusicVolume(param1:Number) : *
- {
- var _loc2_:TFSound = null;
- var _loc3_:* = undefined;
- if(param1 > 100)
- {
- param1 = 100;
- }
- else if(param1 < 0)
- {
- param1 = 0;
- }
- MUSIC_VOLUME = param1;
- for(_loc3_ in arSound)
- {
- _loc2_ = arSound[_loc3_] as TFSound;
- if(_loc2_.getType() == TFSound.TYPE_MUSIC)
- {
- _loc2_.setVolume(MUSIC_VOLUME);
- }
- }
- }
-
- public function getMusicVolume() : Number
- {
- return MUSIC_VOLUME;
- }
-
- public function removeSound(param1:TFSound) : Boolean
- {
- var _loc2_:Number = NaN;
- _loc2_ = 0;
- while(_loc2_ < arSound.length)
- {
- if(arSound[_loc2_] as TFSound == param1)
- {
- param1.stop();
- arSound.splice(_loc2_,1);
- return true;
- }
- _loc2_++;
- }
- return false;
- }
-
- public function addSound(param1:TFSound) : Boolean
- {
- var _loc2_:* = undefined;
- for(_loc2_ in arSound)
- {
- if(arSound[_loc2_] as TFSound == param1)
- {
- return false;
- }
- }
- arSound.push(param1);
- switch(param1.getType())
- {
- case TFSound.TYPE_MUSIC:
- param1.setVolume(MUSIC_VOLUME);
- break;
- case TFSound.TYPE_SFX:
- param1.setVolume(SFX_VOLUME);
- }
- return true;
- }
-
- public function process(param1:Object) : *
- {
- var _loc2_:* = undefined;
- for(_loc2_ in arSound)
- {
- (arSound[_loc2_] as TFSound).process(param1);
- }
- }
-
- public function getSFXVolume() : Number
- {
- return SFX_VOLUME;
- }
-
- public function setSFXVolume(param1:Number) : *
- {
- var _loc2_:TFSound = null;
- var _loc3_:* = undefined;
- if(param1 > 100)
- {
- param1 = 100;
- }
- else if(param1 < 0)
- {
- param1 = 0;
- }
- SFX_VOLUME = param1;
- for(_loc3_ in arSound)
- {
- _loc2_ = arSound[_loc3_] as TFSound;
- if(_loc2_.getType() == TFSound.TYPE_SFX)
- {
- _loc2_.setVolume(SFX_VOLUME);
- }
- }
- }
- }
- }
-