home *** CD-ROM | disk | FTP | other *** search
- class com.argosy.ui.ActivityTimer extends com.argosy.ui.baseUI
- {
- var duration_time;
- var start_time;
- var update_interval;
- var time_tf;
- var elapsed_time;
- var dispatchEvent;
- var time_style;
- var bg;
- var drop_shadow;
- var useRelativeTime = false;
- function ActivityTimer()
- {
- super();
- }
- function start_timer(duration)
- {
- trace("•••••••••••••••••••••••••••Start•Timer•" + duration + "••••••••••••••••••••••••••••••");
- this.duration_time = duration * 60 * 1000;
- this.start_time = getTimer();
- this.update_interval = setInterval(this,"update_timer",200);
- }
- function clear_timer()
- {
- this.stop_timer();
- this.time_tf.htmlText = "";
- }
- function stop_timer()
- {
- clearInterval(this.update_interval);
- this.duration_time -= this.elapsed_time;
- }
- function restart_timer()
- {
- this.start_time = getTimer();
- this.update_interval = setInterval(this,"update_timer",200);
- }
- function get_elapsed_time()
- {
- return this.elapsed_time;
- }
- function get_duration_time()
- {
- return this.duration_time;
- }
- function update_timer()
- {
- this.elapsed_time = getTimer() - this.start_time;
- var _loc2_ = 0;
- if(this.elapsed_time < this.duration_time)
- {
- _loc2_ = (this.duration_time - this.elapsed_time) / 1000;
- }
- else
- {
- clearInterval(this.update_interval);
- this.dispatchEvent({type:"time_up",target:this});
- }
- if(_loc2_ < 60)
- {
- this.time_tf.htmlText = "<p>Time Left: <warn>00:" + (String(Math.floor(_loc2_)).length != 1 ? "" : "0") + Math.floor(_loc2_) + "</p>";
- }
- else if(_loc2_ < 120 || this.useRelativeTime == false)
- {
- var _loc4_ = Math.floor(_loc2_ / 60);
- var _loc3_ = Math.floor(_loc2_ - _loc4_ * 60);
- this.time_tf.htmlText = "<p>Time Left: " + _loc4_ + ":" + (String(_loc3_).length != 1 ? "" : "0") + _loc3_ + "</p>";
- }
- else
- {
- _loc4_ = Math.floor(_loc2_ / 60);
- this.time_tf.htmlText = "<p>Time Left: " + _loc4_ + " Minutes.</p>";
- }
- this.setSize(this.time_tf._width,this.time_tf._height);
- }
- function init()
- {
- trace("•••••••••••••••••••••••••••Init•Timer•••••••••••••••••••••••••••••••");
- this.time_style = new TextField.StyleSheet();
- this.time_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#000000",textAlign:"left",textDecoration:"none",kerning:"true",letterSpacing:"0"});
- this.time_style.setStyle("warn",{color:"#FF0000"});
- super.init();
- }
- function createChildren()
- {
- this.bg = this.createEmptyMovieClip("bg",1);
- this.time_tf = this._createTextField(this,"time_tf",5,0,0,this.width,20,this.time_style,"");
- this.time_tf.autoSize = true;
- this.drop_shadow = new flash.filters.DropShadowFilter(5,45,0,0.8,10,10,1,3);
- }
- function layout()
- {
- this.bg.clear();
- this.bg.beginFill(16777215,100);
- com.drawing.drawUtil.drawRect(this.bg,0,0,this.width,this.height,0);
- this.bg.endFill();
- }
- }
-