Strona 1 z 1

Timer problem

: czw sty 17, 2008 7:46 pm
autor: john14
Zrobilem Timer, jednak mam jeden problem, chce zeby zamiast "2 sekund" pokazywal "02 sekund".

Oto kod.

Kod: Zaznacz cały

Date.prototype.countDown = function( ){

var d = this - new Date();

var s = Math.floor(d/1000);

var m = Math.floor(s/60);

var h = Math.floor(m/60);

var d = Math.floor(h/24);

return d+" "+( h%24 )+" "+(m%60 )+" "+(s%60 )+" ";

}

this.createTextField( "w",1,0,0,500,38 );

this.onEnterFrame = function(){

var d = new Date( 2009,3, 19, 12, 0 );

czas.text= d.countDown() ;;
}
stop();

Re: Timer problem

: czw sty 17, 2008 8:14 pm
autor: Marek_bf
Patrz [NOWE FAQ] -> Date

Re: Timer problem

: pt sty 18, 2008 1:25 pm
autor: john14
Ok, dzieki a jak zrobic zeby po skonczeniu odliczenia timer przeszedl np: do 2 klatki?

Jestem zielony w sprawie AS wiec prosze o wyrozumialosc.

Re: Timer problem

: pt sty 18, 2008 2:24 pm
autor: Marek_bf

Kod: Zaznacz cały

Date.prototype.countDown = function() {
	var d = this - new Date();
	var s = Math.floor(d / 1000);
	var m = Math.floor(s / 60);
	var h = Math.floor(m / 60);
	var d = Math.floor(h / 24);
	if (d > -1) {
		return d + " " + (h % 24) + " " + (m % 60) + " " + (s % 60) + " ";
	} else {
		return false;
	}
};
this.createTextField("czas", 1, 0, 0, 500, 38);
this.onEnterFrame = function() {
	var d = new Date(2009, 3, 19, 12, 0);
	if (d.countDown()) {
		czas.text = d.countDown();
	} else {
		czas.text = "koniec czasu";
		jakisKlip.gotoAndStop(2);
		delete this.onEnterFrame;
	}
};
stop();