home *** CD-ROM | disk | FTP | other *** search
/ Practice Anatomy Lab / PAL.ISO / pc / PAL.swf / scripts / __Packages / com / argosy / ui / ActivityTimer.as next >
Encoding:
Text File  |  2007-03-19  |  3.4 KB  |  100 lines

  1. class com.argosy.ui.ActivityTimer extends com.argosy.ui.baseUI
  2. {
  3.    var duration_time;
  4.    var start_time;
  5.    var update_interval;
  6.    var time_tf;
  7.    var elapsed_time;
  8.    var dispatchEvent;
  9.    var time_style;
  10.    var bg;
  11.    var drop_shadow;
  12.    var useRelativeTime = false;
  13.    function ActivityTimer()
  14.    {
  15.       super();
  16.    }
  17.    function start_timer(duration)
  18.    {
  19.       trace("‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢Start‚Ä¢Timer‚Ä¢" + duration + "‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢");
  20.       this.duration_time = duration * 60 * 1000;
  21.       this.start_time = getTimer();
  22.       this.update_interval = setInterval(this,"update_timer",200);
  23.    }
  24.    function clear_timer()
  25.    {
  26.       this.stop_timer();
  27.       this.time_tf.htmlText = "";
  28.    }
  29.    function stop_timer()
  30.    {
  31.       clearInterval(this.update_interval);
  32.       this.duration_time -= this.elapsed_time;
  33.    }
  34.    function restart_timer()
  35.    {
  36.       this.start_time = getTimer();
  37.       this.update_interval = setInterval(this,"update_timer",200);
  38.    }
  39.    function get_elapsed_time()
  40.    {
  41.       return this.elapsed_time;
  42.    }
  43.    function get_duration_time()
  44.    {
  45.       return this.duration_time;
  46.    }
  47.    function update_timer()
  48.    {
  49.       this.elapsed_time = getTimer() - this.start_time;
  50.       var _loc2_ = 0;
  51.       if(this.elapsed_time < this.duration_time)
  52.       {
  53.          _loc2_ = (this.duration_time - this.elapsed_time) / 1000;
  54.       }
  55.       else
  56.       {
  57.          clearInterval(this.update_interval);
  58.          this.dispatchEvent({type:"time_up",target:this});
  59.       }
  60.       if(_loc2_ < 60)
  61.       {
  62.          this.time_tf.htmlText = "<p>Time Left: <warn>00:" + (String(Math.floor(_loc2_)).length != 1 ? "" : "0") + Math.floor(_loc2_) + "</p>";
  63.       }
  64.       else if(_loc2_ < 120 || this.useRelativeTime == false)
  65.       {
  66.          var _loc4_ = Math.floor(_loc2_ / 60);
  67.          var _loc3_ = Math.floor(_loc2_ - _loc4_ * 60);
  68.          this.time_tf.htmlText = "<p>Time Left: " + _loc4_ + ":" + (String(_loc3_).length != 1 ? "" : "0") + _loc3_ + "</p>";
  69.       }
  70.       else
  71.       {
  72.          _loc4_ = Math.floor(_loc2_ / 60);
  73.          this.time_tf.htmlText = "<p>Time Left: " + _loc4_ + " Minutes.</p>";
  74.       }
  75.       this.setSize(this.time_tf._width,this.time_tf._height);
  76.    }
  77.    function init()
  78.    {
  79.       trace("‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢Init‚Ä¢Timer‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢‚Ä¢");
  80.       this.time_style = new TextField.StyleSheet();
  81.       this.time_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#000000",textAlign:"left",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  82.       this.time_style.setStyle("warn",{color:"#FF0000"});
  83.       super.init();
  84.    }
  85.    function createChildren()
  86.    {
  87.       this.bg = this.createEmptyMovieClip("bg",1);
  88.       this.time_tf = this._createTextField(this,"time_tf",5,0,0,this.width,20,this.time_style,"");
  89.       this.time_tf.autoSize = true;
  90.       this.drop_shadow = new flash.filters.DropShadowFilter(5,45,0,0.8,10,10,1,3);
  91.    }
  92.    function layout()
  93.    {
  94.       this.bg.clear();
  95.       this.bg.beginFill(16777215,100);
  96.       com.drawing.drawUtil.drawRect(this.bg,0,0,this.width,this.height,0);
  97.       this.bg.endFill();
  98.    }
  99. }
  100.