home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FCE Gold Plus
/
GOLD.iso
/
pc
/
shell.swf
/
scripts
/
__Packages
/
com
/
comp
/
Timer.as
< prev
next >
Wrap
Text File
|
2007-10-16
|
5KB
|
173 lines
class com.comp.Timer
{
var c_boolVar = true;
function Timer(_objRoot, _iTotTime, _iTotSecTime, _strSourceClip, _strMinField, _objTestRef)
{
var _loc1_ = this;
_loc1_.c_objRef = _objRoot;
_loc1_.c_mcSourceRef = _objRoot[_strSourceClip];
_loc1_.c_txtMinRef = _loc1_.c_mcSourceRef[_strMinField];
_loc1_.c_iTotalTime = _iTotTime;
_loc1_.c_objTestRef = _objTestRef;
_loc1_.init(_iTotTime,_iTotSecTime);
}
function init(_iMinutes, _iSeconds)
{
var _loc1_ = this;
_loc1_.c_iMins = Number(_iMinutes);
_loc1_.c_iTimerDuration = Number(_iMinutes);
_loc1_.c_iSecs = Number(_iSeconds);
_loc1_.c_iMins = _loc1_.c_iMins - 1;
_loc1_.changedTime();
_loc1_.c_txtMinRef.htmlText = "<b>" + _loc1_.c_iChangedMins + "</b>" + " mins";
if(_loc1_.c_iMins < 10)
{
_loc1_.c_iMins = "0" + _loc1_.c_iMins;
}
_loc1_.arrange();
}
function arrange()
{
this.startTimer();
}
function startTimer()
{
var _loc1_ = this;
_loc1_.c_objInterval = setInterval(_loc1_.showTimer,1000,_loc1_);
}
function stopTimer()
{
clearInterval(this.c_objInterval);
}
function showTimer(_objRef)
{
with(_objRef)
{
if(c_iSecs <= 0)
{
c_iSecs = 60;
actualTime();
}
c_iSecs--;
if(c_iSecs < 10)
{
c_iSecs = "0" + c_iSecs;
}
if(c_iMins == 15 || c_iMins == 5)
{
if(c_iMins == 5)
{
c_blnPopUp = false;
}
if(!c_blnPopUp && c_iSecs == 0)
{
_objRef = _level101.mc_PopUp;
_objRef.gotoAndStop("timeleft");
c_blnPopUp = true;
_objRef._x = 232.9;
_objRef._y = 181.4;
_objRef.txt_TimeLeft.text = Number(c_iMins) + " mins remaining";
_objRef.btn_backtotest.onRelease = function()
{
_objRef.gotoAndStop("blank");
};
}
}
if(c_iSecs <= 0 && c_iMins <= 0)
{
gameOver();
stopTimer();
}
}
_objRef.setEvents(_objRef);
_objRef.setTimer();
_objRef.getminsTime();
}
function setEvents(_objRef)
{
this.c_mcSourceRef.onRollOver = function()
{
_objRef.c_boolVar = false;
_objRef.setTimer();
};
this.c_mcSourceRef.onRollOut = function()
{
_objRef.c_boolVar = true;
_objRef.setTimer();
};
}
function setTimer()
{
var _loc1_ = this;
if(_loc1_.c_iMins <= 10)
{
_loc1_.c_txtMinRef.textColor = 65295;
}
if(_loc1_.c_boolVar)
{
_loc1_.c_txtMinRef.htmlText = "<p><b>" + _loc1_.c_iChangedMins + "</b>" + " mins" + "</p>";
}
else
{
_loc1_.c_txtMinRef.htmlText = "<p align=\'center\'><b>" + _loc1_.c_iMins + ":" + _loc1_.c_iSecs + "</b></p>";
}
}
function actualTime()
{
var _loc1_ = this;
_loc1_.c_iMins = _loc1_.c_iMins - 1;
if(_loc1_.c_iMins < 10)
{
_loc1_.c_iMins = "0" + _loc1_.c_iMins;
}
_loc1_.changedTime();
return _loc1_.c_iMins;
}
function changedTime()
{
var _loc2_ = this;
var _loc1_ = Number(_loc2_.c_iMins) + Number(1);
if(_loc1_ < 10)
{
_loc2_.c_iChangedMins = "0" + _loc1_;
}
else
{
_loc2_.c_iChangedMins = _loc1_;
}
return _loc2_.c_iChangedMins;
}
function gameOver()
{
trace("Game Over");
clearInterval(this.c_objInterval);
this.c_objTestRef.popupNo();
}
function alerts()
{
trace("YOU HAVE ONLY 15 MINS");
}
function resetTimer()
{
this.init(this.c_iTimerDuration);
}
function destroyTimer()
{
clearInterval(this.c_objInterval);
this.c_mcSourceRef.removeMovieClip();
}
function getMinsTime()
{
var _loc1_ = undefined;
_loc1_ = Number(this.c_iTotalTime) - Math.floor(Number(this.c_iMins));
return _loc1_;
}
function getSecTime()
{
var _loc1_ = this;
var _min = Math.floor(_loc1_.c_iMins / 60);
var _sec = _loc1_.c_iMins % 60;
return _loc1_.c_iMins + "." + _loc1_.c_iSecs;
}
}