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

  1. class Ticker
  2. {
  3.    var _direction;
  4.    var _textField;
  5.    var _clearID;
  6.    var _options;
  7.    function Ticker(textField, options)
  8.    {
  9.       this._direction = "fw";
  10.       this._textField = textField;
  11.       this._clearID = null;
  12.       this._options = {pause:6000,interval:25,increment:1};
  13.       if(typeof options == "Object")
  14.       {
  15.          this.setOptions(options);
  16.       }
  17.    }
  18.    function setOptions(options)
  19.    {
  20.       for(var _loc3_ in options)
  21.       {
  22.          this._options[_loc3_] = options[_loc3_];
  23.       }
  24.    }
  25.    function start()
  26.    {
  27.       this._clearID = setInterval(this,"_start",this._options.pause);
  28.    }
  29.    function reset()
  30.    {
  31.       clearInterval(this._clearID);
  32.       this._textField.hscroll = 0;
  33.       this.start();
  34.    }
  35.    function _start()
  36.    {
  37.       if(this._textField.maxhscroll == 0)
  38.       {
  39.          return undefined;
  40.       }
  41.       clearInterval(this._clearID);
  42.       this._clearID = setInterval(this,"_scroll",this._options.interval);
  43.    }
  44.    function _scroll()
  45.    {
  46.       if(this._direction == "fw" && this._textField.hscroll == this._textField.maxhscroll)
  47.       {
  48.          this._direction = "bw";
  49.          clearInterval(this._clearID);
  50.          this._clearID = setInterval(this,"_start",this._options.pause);
  51.          return undefined;
  52.       }
  53.       if(this._direction == "bw" && this._textField.hscroll == 0)
  54.       {
  55.          this._direction = "fw";
  56.          clearInterval(this._clearID);
  57.          this._clearID = setInterval(this,"_start",this._options.pause);
  58.          return undefined;
  59.       }
  60.       if(this._direction == "fw")
  61.       {
  62.          this._textField.hscroll += this._options.increment;
  63.       }
  64.       else
  65.       {
  66.          this._textField.hscroll -= this._options.increment;
  67.       }
  68.    }
  69. }
  70.