home *** CD-ROM | disk | FTP | other *** search
- class Volume extends MovieClip
- {
- var control_mc;
- var button_mc;
- var icon_mc;
- var _settingVolume;
- var _initialMaskPos;
- var realWidth;
- var background_mc;
- var broadcastMessage;
- var _clearID;
- var _rtl = false;
- function Volume()
- {
- super();
- AsBroadcaster.initialize(this);
- this.control_mc._alpha = 0;
- this.button_mc._visible = false;
- this.icon_mc._alpha = 100;
- this._settingVolume = false;
- this._initialMaskPos = this.control_mc.mask_mc._x;
- this.realWidth = this.background_mc._width;
- this.button_mc.onPress = mx.utils.Delegate.create(this,function()
- {
- this._settingVolume = true;
- this._moveVolumeBar();
- }
- );
- this.button_mc.onMouseMove = mx.utils.Delegate.create(this,function()
- {
- if(this._settingVolume)
- {
- this._moveVolumeBar();
- this.broadcastMessage("onSetVolume",this._getValue(),false);
- }
- }
- );
- this.button_mc.onRelease = this.button_mc.onReleaseOutside = mx.utils.Delegate.create(this,function()
- {
- this._settingVolume = false;
- this._moveVolumeBar();
- this.broadcastMessage("onSetVolume",this._getValue(),true);
- }
- );
- }
- function update(volume)
- {
- if(!this._settingVolume)
- {
- this.control_mc.mask_mc._x = this._initialMaskPos + Math.round(this.control_mc.track_mc._width * volume / 100);
- }
- }
- function _moveVolumeBar()
- {
- if(this.control_mc.track_mc._xmouse > this.control_mc.track_mc._width)
- {
- this.control_mc.mask_mc._x = this._initialMaskPos + this.control_mc.track_mc._width;
- }
- else if(this.control_mc.track_mc._xmouse < 0)
- {
- this.control_mc.mask_mc._x = this._initialMaskPos;
- }
- else
- {
- this.control_mc.mask_mc._x = this._initialMaskPos + this.control_mc.track_mc._xmouse;
- }
- }
- function _getValue()
- {
- return Math.round((this.control_mc.mask_mc._x - this._initialMaskPos) / this.control_mc.track_mc._width * 100);
- }
- function toggleControl(toggle, immediate)
- {
- clearInterval(this._clearID);
- if(toggle)
- {
- this._clearID = setInterval(this,"_animate",41,100,0,!this._rtl ? 6 : 11);
- }
- else
- {
- this._clearID = setInterval(this,"_animate",41,0,100,!this._rtl ? 16 : 21);
- }
- }
- function _animate(targetControl, targetIcon, targetIconX)
- {
- var _loc2_ = targetControl - this.control_mc._alpha;
- var _loc5_ = targetIcon - this.icon_mc._alpha;
- var _loc4_ = targetIconX - this.icon_mc._x;
- var _loc3_ = 0.3;
- _loc2_ *= _loc3_;
- _loc5_ *= _loc3_;
- _loc4_ *= _loc3_;
- if(Math.abs(_loc2_) < 1)
- {
- this.control_mc._alpha = targetControl;
- this.icon_mc._alpha = targetIcon;
- this.icon_mc._x = targetIconX;
- this.button_mc._visible = this.control_mc._alpha == 100;
- clearInterval(this._clearID);
- return undefined;
- }
- this.control_mc._alpha += _loc2_;
- this.icon_mc._alpha += _loc5_;
- this.icon_mc._x += _loc4_;
- }
- function flip()
- {
- this._rtl = true;
- this.background_mc._rotation = 180;
- this.background_mc._y += this.background_mc._height;
- this.background_mc._x += this.background_mc._width;
- this.control_mc._x += 5;
- this.icon_mc._x += 5;
- }
- }
-