home *** CD-ROM | disk | FTP | other *** search
- class Display extends MovieClip
- {
- var _messages;
- var _currentSlot;
- var _ticker;
- var message_txt;
- var time_txt;
- var _newWidth;
- function Display()
- {
- super();
- this._messages = new Array();
- this._currentSlot = 0;
- this._ticker = new Ticker(this.message_txt);
- this._ticker.start();
- }
- function next()
- {
- this._currentSlot = ++this._currentSlot != this._messages.length ? this._currentSlot : 0;
- this._update();
- }
- function setText(text, slot, forceDisplay)
- {
- if(forceDisplay == undefined)
- {
- forceDisplay = false;
- }
- var _loc3_ = false;
- if(this._currentSlot == slot && this._messages[slot] != text)
- {
- _loc3_ = true;
- }
- if(forceDisplay && this._messages[slot] != text)
- {
- this._currentSlot = slot;
- _loc3_ = true;
- }
- this._messages[slot] = text;
- if(_loc3_)
- {
- this._update();
- }
- }
- function setTime(ms, isRemaining)
- {
- var _loc2_ = !(isRemaining && ms > 0) ? "" : "-";
- this.time_txt.text = _loc2_ + this._formatTime(ms);
- this.resize();
- }
- function clear()
- {
- this._messages = new Array();
- this._currentSlot = 0;
- this.message_txt.text = "";
- this.time_txt.text = "";
- this._ticker.reset();
- }
- function resize(newWidth)
- {
- if(newWidth != undefined)
- {
- this._newWidth = newWidth;
- }
- var _loc2_ = this._newWidth;
- _loc2_ -= this.time_txt.text.length <= 5 ? 38 : 50;
- this.message_txt._width = _loc2_;
- this.time_txt._x = this._newWidth - this.time_txt._width + 1;
- }
- function _update()
- {
- this.message_txt.text = this._messages[this._currentSlot];
- this._ticker.reset();
- }
- function _formatTime(ms)
- {
- var _loc2_ = new Date();
- var _loc3_ = undefined;
- var _loc4_ = undefined;
- var _loc5_ = undefined;
- var _loc1_ = undefined;
- _loc2_.setSeconds(int(ms / 1000));
- _loc2_.setMinutes(int(ms / 1000 / 60));
- _loc2_.setHours(int(ms / 1000 / 60 / 60));
- _loc3_ = _loc2_.getSeconds();
- _loc4_ = _loc2_.getMinutes();
- _loc5_ = _loc2_.getHours();
- _loc1_ = _loc3_.toString();
- if(_loc3_ < 10)
- {
- _loc1_ = "0" + _loc1_;
- }
- _loc1_ = ":" + _loc1_;
- _loc1_ = _loc4_.toString() + _loc1_;
- if(_loc5_ > 0)
- {
- if(_loc4_ < 10)
- {
- _loc1_ = "0" + _loc1_;
- }
- _loc1_ = ":" + _loc1_;
- _loc1_ = _loc5_.toString() + _loc1_;
- }
- return _loc1_;
- }
- }
-