Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/11/2006, 14:04
Avatar de PumasCampeon
PumasCampeon
 
Fecha de Ingreso: junio-2004
Ubicación: @gs.mx
Mensajes: 240
Antigüedad: 19 años, 10 meses
Puntos: 0
me lo pasaron aqui mismo.... e hice algunas pruebas...!
te lo paso, Salu2!
Código:
function actualizarFecha() {
	delete nuevaFecha;
	var nuevaFecha:Date = new Date();
	//
	var periodo2Mins:Date = new Date();
	var lapsoAnho = Number(periodo2Mins.getFullYear());
	var lapsoMes = periodo2Mins.getMonth();
	var lapsoDiaNum = periodo2Mins.getDate()+1;
	var lapsoHr = Number(periodo2Mins.getHours()+1);
	var lapsoMin = Number(periodo2Mins.getMinutes()+1);
	var lapsoSeg = Number(periodo2Mins.getSeconds()+1);
	trace('minuto actual >> '+periodo2Mins.getMinutes()+' >> (-2) >> '+lapsoMin+', '+lapsoSeg);	// p.e. --> 14 - 2 = 12
	// endDate [año, mes (0-11), dia(1-31), hora, min, seg, mili]
	//endDate = new Date(lapsoAnho, lapsoMes, lapsoDiaNum, lapsoHr, lapsoMin, lapsoSeg, 00);
	endDate = new Date(lapsoAnho, lapsoMes, lapsoDiaNum, 12, 12, 00, 00);
	trace('fecha actual: '+endDate);
	fecha_btn.enabled = false;
	timeLeft = (endDate-nuevaFecha);
}
//
actualizarFecha() 
//
var d = 24*60*60*1000;
var h = 60*60*1000;
var m = 60*1000;
var s = 1000;
MathDosDigitos = function (value) {
	return (value<10) ? ("0"+value) : (value);
};
function calculate(factor) {
	var result = Math.floor(timeLeft/factor);
	timeLeft -= (result*factor);
	return MathDosDigitos(result);
}
getTimeLeft = function () {
	timeLeft = (endDate-new Date());
	if (minutos == 0 && segundos == 0) {
		//(timeLeft>0) {
		//se acabo el tiempo;
		trace('se acabo el tiempo;');
		campo.text = "00 : 00";
		clearInterval(id);
		fecha_btn.enabled = true;
	} else {
		dias = calculate(d);
		horas = calculate(h);
		minutos = calculate(m);
		segundos = MathDosDigitos(Math.floor(timeLeft/1000));
		//trace (minutos+' : '+segundos);
		campo.text = (dias>0)? dias+"falta: día(s), "+horas+" : "+minutos+" : "+segundos : "falta: "+horas+" : "+minutos+" : "+segundos;
		//campo.text = (minutos == 1 && segundos>58) ? "01 : 59" : minutos+" : "+segundos;
	}
};
this.createTextField("campo", 1, 0, 0, 0, 0);
this.campo.autoSize = true;
var id = setInterval(getTimeLeft, 1000);
//
stop();
//
var hrTranscurridos;
var minTranscurridos;
var segTranscurridos;
/*this.createTextField("timer_txt", this.getNextHighestDepth(), 100, 0, 100, 22);
this.createTextField("tiempoTrans_txt", this.getNextHighestDepth(), 100, 20, 100, 22);*/
function updateTimer():Void {
	 timer_txt.text = getTimer();
	 //
	 minTranscurridos = Math.floor(getTimer()*.001/60);
	 segTranscurridos = Math.floor(getTimer()*.001);
	 tiempoTrans_txt.text = hrTranscurridos+' : '+minTranscurridos+' : '+segTranscurridos;
}

var intervalID:Number = setInterval(updateTimer, 100);
__________________
lo que se es una gota de lluvia, comparado con tu inmenso mar :-)