home *** CD-ROM | disk | FTP | other *** search
Wrap
class com.neodelight.std.XSound extends Sound { var channels; var groups; var master; var channelsAmount = 8; function XSound() { super(); this.channels = new Array(this.channelsAmount); this.groups = {fx:1,music:1}; var _loc4_ = 0; while(_loc4_ < this.channelsAmount) { this.channels[_loc4_] = new com.neodelight.std.XSoundChannel(_loc4_,_root.createEmptyMovieClip(com.neodelight.std.Unique.getKey(),_root.getNextHighestDepth()),this.groups); _loc4_ = _loc4_ + 1; } this.master = new Sound(); this.master.setVolume(100); } function addGroup(id) { this.groups[id] = 1; } function setVolume(volume) { this.master.setVolume(volume * 100); } function getVolume() { return this.master.getVolume() * 0.01; } function setGroupVolume(volume, id) { this.groups[id] = volume; var _loc2_ = this.channels.length; while(_loc2_--) { this.channels[_loc2_].setVolume(); } } function getGroupVolume(id) { return this.groups[id]; } function playLoop(libId, volume, group) { var _loc2_ = this.getChannel(); _loc2_.attachSound(libId); _loc2_.start(0,99999); _loc2_.group = !group ? "music" : group; _loc2_.setVolume(volume); _loc2_.libId = libId; _loc2_.locked = true; _loc2_.playing = true; return _loc2_; } function playEvent(libId, volume, group) { trace("snd: " + libId); var _loc2_ = this.getChannel(); _loc2_.attachSound(libId); _loc2_.start(0,0); _loc2_.group = !group ? "fx" : group; _loc2_.setVolume(volume); _loc2_.libId = libId; _loc2_.playing = true; return _loc2_; } function getChannel() { var _loc4_ = -1; var _loc5_ = -1; var _loc3_ = 0; while(_loc3_ < this.channels.length) { var _loc2_ = this.channels[_loc3_]; if(!_loc2_.locked) { if(!_loc2_.playing) { return this.channels[_loc3_]; } if(_loc2_.position > _loc4_) { _loc4_ = _loc2_.position; _loc5_ = _loc2_.id; } } _loc3_ = _loc3_ + 1; } if(_loc5_ != -1) { return this.channels[_loc5_]; } } function fadeChannel(channel, fadeTo, time) { if(fadeTo < 0) { channel.fadeOutFlag = true; fadeTo = 0; } if(time <= 0) { channel.setVolume(fadeTo * 100); channel.fading = false; } else { channel.fading = true; channel.fadeTo = Math.min(100,fadeTo * 100); channel.fadeSpeed = (fadeTo - channel.getVolume()) / time; } } function stop(libId) { var _loc2_ = 0; while(_loc2_ < this.channels.length) { if(this.channels[_loc2_].libId == libId || !libId) { this.channels[_loc2_].stop(); } _loc2_ = _loc2_ + 1; } } }