-
How to sum total time from 50 timers?
Hello?
I am frustrated with this project. My
flash movie shows 50 timers; one timer per frame on 50 frames;
I have a global function in the top Layer
now I need to show the total sum of all timers in a single text field using a loop in every frame that holds myTimer code
//first frame/timer
var i:Number;
for (i = 0; i < mySum.length; i++) {
totalTimers.text =(mySum[i].Sum);
}
totalTimers.text = i;
//second frame/timer
var i:Number;
for (i = 1; i < mySum.length; i++) {
totalTimers.text =(mySum[i].Sum);
}
totalTimers.text = i;
...
//fifthy frame/timer
var i:Number;
for (i = 49; i < mySum.length; i++) {
totalTimers.text =(mySum[i].Sum);
__________________________________________________ _
//Global function
_global.stopWatch = function(){
this.time = 0;
this.start = function(){
clearInterval(this.watchID);
this.p = getTimer();
this.ctime = this.time;
var timer = function (stopwatch){
stopwatch.time = stopwatch.ctime + getTimer()- stopwatch.p;
};
this.watchID = setInterval(timer, 1, this);
};
this.stop = function(){
clearInterval(this.watchID);
};
this.reset = function(){
clearInterval(this.watchID);
this.time = 0;
}
this.toString = function(){
var ntime = this.time;
var hours = Math.floor(ntime/3600000);
ntime-=hours*3600000;
var minutes = Math.floor(ntime/60000);
ntime-=minutes*60000;
var seconds = Math.floor(ntime/1000);
ntime-=seconds*1000;
var milliseconds = ntime;
if(hours<10)hours = '0'+hours;
if(minutes<10)minutes = '0'+minutes;
if(seconds<10)seconds = '0'+seconds;
if(milliseconds<10)milliseconds = '0'+milliseconds;
return hours+':'+minutes+':'+seconds;
}
}
// this code goes in 50 frames changing the var myTimer.
i.e. myTimer1, my Timer2 ... myTimer50
stop();
myTimer1 = new stopWatch();
this.onEnterFrame = function(){
timeText1.text = myTimer1;
totalTimers.text = myTimer1;
}
start_btn.onPress = function(){
myTimer1.start();
}
stop_btn.onPress = function(){
myTimer1.stop();
}
reset_btn.onPress = function(){
myTimer1.reset();
}
myTimer1.start();
please help, Im very frustrated with this assigment, I will appreciate it so much!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|