Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/03/2013, 23:02
escorlapio2000
 
Fecha de Ingreso: marzo-2013
Mensajes: 2
Antigüedad: 11 años, 1 mes
Puntos: 0
Como sumar el tiempo de 50 cronometros?

Que tal?
he buscado por semanas la respuesta a mi problema en diferentes foros en la Web y nadie me ha dado respuesta. Necesito sumar el tiempo total registrado de 50 cronometros y mostrar el resultado o suma total en un campo de texto dinamico.

Podria alguien decirme si conocen de algun tutorial que muestre codigo relacionado a lo que quiero desarrollar o ayudarme a componer mi codigo?


1. Tengo un layer que contiene el siguiente codigo hasta el frame 50:


_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;
}
}

2. ademas tengo un segundo layer con 50 frames indivuiduales con el siguiente codigo, cambiando el numero de la variable myTimer1 ... myTimer50:


stop();

myTimer1 = new stopWatch();
this.onEnterFrame = function(){
timeText1.text = myTimer1;
}
start_btn.onPress = function(){
myTimer1.start();
}
stop_btn.onPress = function(){
myTimer1.stop();
}
reset_btn.onPress = function(){
myTimer1.reset();
}
myTimer1.start();


3. intento usar el siguiente codigo para sumar el tiempo transcurrido de cada cronometro en un solo campo de texto dinamico pero aun no se como lograrlo. . ..

for (i = 1; i < 50; i++)
{
this["text" + i].text = "0";
}
_root.onEnterFrame = function()
{
text5.text = Number(myTimer1.text) + Number(myTimer2.text) + Number(myTimer3.text) . . . . . + Number(myTimer50.text);
}



muchas gracias por su tiempo