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

  1. class Display extends MovieClip
  2. {
  3.    var _messages;
  4.    var _currentSlot;
  5.    var _ticker;
  6.    var message_txt;
  7.    var time_txt;
  8.    var _newWidth;
  9.    function Display()
  10.    {
  11.       super();
  12.       this._messages = new Array();
  13.       this._currentSlot = 0;
  14.       this._ticker = new Ticker(this.message_txt);
  15.       this._ticker.start();
  16.    }
  17.    function next()
  18.    {
  19.       this._currentSlot = ++this._currentSlot != this._messages.length ? this._currentSlot : 0;
  20.       this._update();
  21.    }
  22.    function setText(text, slot, forceDisplay)
  23.    {
  24.       if(forceDisplay == undefined)
  25.       {
  26.          forceDisplay = false;
  27.       }
  28.       var _loc3_ = false;
  29.       if(this._currentSlot == slot && this._messages[slot] != text)
  30.       {
  31.          _loc3_ = true;
  32.       }
  33.       if(forceDisplay && this._messages[slot] != text)
  34.       {
  35.          this._currentSlot = slot;
  36.          _loc3_ = true;
  37.       }
  38.       this._messages[slot] = text;
  39.       if(_loc3_)
  40.       {
  41.          this._update();
  42.       }
  43.    }
  44.    function setTime(ms, isRemaining)
  45.    {
  46.       var _loc2_ = !(isRemaining && ms > 0) ? "" : "-";
  47.       this.time_txt.text = _loc2_ + this._formatTime(ms);
  48.       this.resize();
  49.    }
  50.    function clear()
  51.    {
  52.       this._messages = new Array();
  53.       this._currentSlot = 0;
  54.       this.message_txt.text = "";
  55.       this.time_txt.text = "";
  56.       this._ticker.reset();
  57.    }
  58.    function resize(newWidth)
  59.    {
  60.       if(newWidth != undefined)
  61.       {
  62.          this._newWidth = newWidth;
  63.       }
  64.       var _loc2_ = this._newWidth;
  65.       _loc2_ -= this.time_txt.text.length <= 5 ? 38 : 50;
  66.       this.message_txt._width = _loc2_;
  67.       this.time_txt._x = this._newWidth - this.time_txt._width + 1;
  68.    }
  69.    function _update()
  70.    {
  71.       this.message_txt.text = this._messages[this._currentSlot];
  72.       this._ticker.reset();
  73.    }
  74.    function _formatTime(ms)
  75.    {
  76.       var _loc2_ = new Date();
  77.       var _loc3_ = undefined;
  78.       var _loc4_ = undefined;
  79.       var _loc5_ = undefined;
  80.       var _loc1_ = undefined;
  81.       _loc2_.setSeconds(int(ms / 1000));
  82.       _loc2_.setMinutes(int(ms / 1000 / 60));
  83.       _loc2_.setHours(int(ms / 1000 / 60 / 60));
  84.       _loc3_ = _loc2_.getSeconds();
  85.       _loc4_ = _loc2_.getMinutes();
  86.       _loc5_ = _loc2_.getHours();
  87.       _loc1_ = _loc3_.toString();
  88.       if(_loc3_ < 10)
  89.       {
  90.          _loc1_ = "0" + _loc1_;
  91.       }
  92.       _loc1_ = ":" + _loc1_;
  93.       _loc1_ = _loc4_.toString() + _loc1_;
  94.       if(_loc5_ > 0)
  95.       {
  96.          if(_loc4_ < 10)
  97.          {
  98.             _loc1_ = "0" + _loc1_;
  99.          }
  100.          _loc1_ = ":" + _loc1_;
  101.          _loc1_ = _loc5_.toString() + _loc1_;
  102.       }
  103.       return _loc1_;
  104.    }
  105. }
  106.