home *** CD-ROM | disk | FTP | other *** search
/ Neil's C++ Stuff / 2016-02-neilstuff-weebly.iso / apps / audioPlayer2.swf / scripts / __Packages / Progress.as < prev    next >
Encoding:
Text File  |  2016-02-05  |  1.6 KB  |  66 lines

  1. class Progress extends MovieClip
  2. {
  3.    var bar_mc;
  4.    var _movingHead;
  5.    var track_mc;
  6.    var broadcastMessage;
  7.    var _maxPos;
  8.    var border_mc;
  9.    function Progress()
  10.    {
  11.       super();
  12.       AsBroadcaster.initialize(this);
  13.       this.bar_mc._width = 0;
  14.       this._movingHead = false;
  15.       this.track_mc.onPress = mx.utils.Delegate.create(this,function()
  16.       {
  17.          this._movingHead = true;
  18.          this._moveProgressBar();
  19.       }
  20.       );
  21.       this.track_mc.onMouseMove = mx.utils.Delegate.create(this,function()
  22.       {
  23.          if(this._movingHead)
  24.          {
  25.             this._moveProgressBar();
  26.          }
  27.       }
  28.       );
  29.       this.track_mc.onRelease = this.track_mc.onReleaseOutside = mx.utils.Delegate.create(this,function()
  30.       {
  31.          this.broadcastMessage("onMoveHead",this.bar_mc._width / this.track_mc._width);
  32.          this._movingHead = false;
  33.       }
  34.       );
  35.    }
  36.    function updateProgress(played)
  37.    {
  38.       if(!this._movingHead)
  39.       {
  40.          this.bar_mc._width = Math.round(played * this.track_mc._width);
  41.       }
  42.    }
  43.    function setMaxValue(maxValue)
  44.    {
  45.       this._maxPos = maxValue * this.track_mc._width;
  46.    }
  47.    function resize(newWidth)
  48.    {
  49.       this.track_mc._width = newWidth - 2;
  50.       this.border_mc._width = newWidth;
  51.    }
  52.    function _moveProgressBar()
  53.    {
  54.       var _loc2_ = this._xmouse - 1;
  55.       if(_loc2_ < 0)
  56.       {
  57.          _loc2_ = 0;
  58.       }
  59.       else if(_loc2_ > this._maxPos)
  60.       {
  61.          _loc2_ = this._maxPos;
  62.       }
  63.       this.bar_mc._width = _loc2_;
  64.    }
  65. }
  66.