Timer problem

Technologia Flash, czyli animacja na potrzeby stron WWW to świat daleko odbiegły od zwykłego programowania i kodu. Zapytaj o pomoc i podziel się z nami Twoimi problemami z zakresu Flasha.
john14
Posty: 5
Rejestracja: czw sty 17, 2008 7:36 pm

Timer problem

Post 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();
Marek_bf
Administrator
Posty: 4419
Rejestracja: czw lut 24, 2005 2:14 am
Kontakt:

Re: Timer problem

Post autor: Marek_bf »

Patrz [NOWE FAQ] -> Date
john14
Posty: 5
Rejestracja: czw sty 17, 2008 7:36 pm

Re: Timer problem

Post 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.
Marek_bf
Administrator
Posty: 4419
Rejestracja: czw lut 24, 2005 2:14 am
Kontakt:

Re: Timer problem

Post 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();
ODPOWIEDZ