home *** CD-ROM | disk | FTP | other *** search
- class Ticker
- {
- var _direction;
- var _textField;
- var _clearID;
- var _options;
- function Ticker(textField, options)
- {
- this._direction = "fw";
- this._textField = textField;
- this._clearID = null;
- this._options = {pause:6000,interval:25,increment:1};
- if(typeof options == "Object")
- {
- this.setOptions(options);
- }
- }
- function setOptions(options)
- {
- for(var _loc3_ in options)
- {
- this._options[_loc3_] = options[_loc3_];
- }
- }
- function start()
- {
- this._clearID = setInterval(this,"_start",this._options.pause);
- }
- function reset()
- {
- clearInterval(this._clearID);
- this._textField.hscroll = 0;
- this.start();
- }
- function _start()
- {
- if(this._textField.maxhscroll == 0)
- {
- return undefined;
- }
- clearInterval(this._clearID);
- this._clearID = setInterval(this,"_scroll",this._options.interval);
- }
- function _scroll()
- {
- if(this._direction == "fw" && this._textField.hscroll == this._textField.maxhscroll)
- {
- this._direction = "bw";
- clearInterval(this._clearID);
- this._clearID = setInterval(this,"_start",this._options.pause);
- return undefined;
- }
- if(this._direction == "bw" && this._textField.hscroll == 0)
- {
- this._direction = "fw";
- clearInterval(this._clearID);
- this._clearID = setInterval(this,"_start",this._options.pause);
- return undefined;
- }
- if(this._direction == "fw")
- {
- this._textField.hscroll += this._options.increment;
- }
- else
- {
- this._textField.hscroll -= this._options.increment;
- }
- }
- }
-