home *** CD-ROM | disk | FTP | other *** search
- class CountDown
- {
- var FRAMERATE = 36;
- var etat = new String();
- var oldEtat = new String();
- var nom = new String();
- var paused = new Boolean();
- var nbItDone = new Number();
- function CountDown(l_nom)
- {
- this.nom = l_nom;
- this.etat = "Idle";
- this.oldEtat = "Idle";
- this.nbItDone = 0;
- this.paused = false;
- }
- function EnterFrame()
- {
- if(!this.paused)
- {
- this[this.etat]();
- }
- }
- function AddTime(l_nbSec)
- {
- this.nbItDone += l_nbSec * this.FRAMERATE;
- }
- function GetCurrentTime()
- {
- var _loc2_ = new Number();
- if(this.etat == "Running")
- {
- _loc2_ = Math.round(this.nbItDone / this.FRAMERATE);
- }
- else
- {
- _loc2_ = null;
- }
- return _loc2_;
- }
- function GetName()
- {
- return this.nom;
- }
- function GetState()
- {
- return this.etat;
- }
- function Idle()
- {
- }
- function Pause()
- {
- this.paused = true;
- }
- function Running()
- {
- if(this.nbItDone <= 0)
- {
- this.etat = "Idle";
- }
- else
- {
- this.nbItDone = this.nbItDone - 1;
- }
- }
- function StartTimer(l_nbSeconds)
- {
- this.nbItDone = l_nbSeconds * this.FRAMERATE;
- this.etat = "Running";
- }
- function StopTimer()
- {
- this.nbItDone = 0;
- this.etat = "Idle";
- }
- function UnPause()
- {
- this.paused = false;
- }
- }
-