summaryrefslogtreecommitdiffstats
path: root/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/originaltexts/actions_timer.txt
blob: 909b3b728a071417c9914814a6b367048bec87b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Timing Functions



StartTime = null; // this variable is set when the start button is pressed

		  // so that the user is not penalized for the loading time of flash



// timer_timeCompute()

// IN : none

// DO : calculates the minutes and seconds elapsed since the user began the simulation

// OUT: print it out into a text field



function timer_timeCompute()

{

	var CurrentTime = (getTimer()-StartTime)/1000; // gets the current time in milliseconds, subtracts the starttime, 

						       // and converts it into seconds.



	var Minute = Math.floor(CurrentTime/60); // get # of minutes in current time

	var Second = Math.floor(((CurrentTime/60) - Minute) * 60); // get # of seconds in current time



	if ((Minute.toString()).length == 1) {

		// adding a zero to # of minutes if it is less than 10 for correct display

		Minute = "0" + Minute;

	}

	

	if ((Second.toString()).length == 1) {

		// adding a zero to # of seconds if it is less than 10 for correct display

		Second = "0" + Second;

	}



	_root.Menu.Clock.TIME = Minute + ":" + Second; // display time elapsed		

}