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 >
Text File  |  2016-02-05  |  3KB  |  100 lines

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