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 >
Text File  |  2016-02-05  |  2KB  |  66 lines

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