![]() |
|
||||||||||
|
|||||
|
[+3 05.08.09]
Регистрация: Sep 2008
Адрес: Ё∙м∙с∙к
Сообщений: 147
|
вопрос наибанальнейший. Я сделал таймер:
onClipEvent (load) {
TimeSec = 0;
secs = 0;
mins = 0;
}
onClipEvent (enterFrame) {
TimeSec = Number(TimeSec+1);
if (TimeSec == 30) {
TimeSec = 0;
secs = Number(secs+1);
_root.sec.text = secs;
}
}
ЗЫ ночами не сплю, аппетит потерял, заболел, захандрил, так сильно ответ нужен... ![]() ![]() ![]()
__________________
не прелюбодействуй с мозгом ближнего своего! Последний раз редактировалось iNils; 13.10.2008 в 09:34. |
|
|||||
|
[+3 16.09.08]
Регистрация: Jan 2008
Адрес: flex.org
Сообщений: 211
|
пример таймера с запуском и остановкой:
Timer = function(start){
this.reset(start);
}
Timer.prototype.start = function(){
if (this._pauseTime){
this._startTime += getTimer() - this._pauseTime;
this._pauseTime = 0;
}else{
this.reset(true);
}
}
Timer.prototype.stop = function(){
if (!this._pauseTime) this._pauseTime = getTimer();
}
Timer.prototype.reset = function(restart){
this._startTime = getTimer();
if (!this._startTime) this._startTime = 1;
if (restart) this._pauseTime = 0;
else this._pauseTime = this._startTime;
}
Timer.prototype.getTime = function(){
if (this._pauseTime) return this._pauseTime - this._startTime;
var gotTime = getTimer();
if (!gotTime) gotTime = 1;
return gotTime - this._startTime;
}
Timer.prototype.setTime = function(t){
this._startTime = getTimer() - t;
}
Timer.prototype.addProperty("time",Timer.prototype.getTime,Timer.prototype.setTime);
Timer.prototype.getPaused = function(){
return (this._pauseTime) ? true : false;
}
Timer.prototype.setPaused = function(p){
if (p == Boolean(this._pauseTime)) return false;
if (p) this.stop();
else this.start();
}
Timer.prototype.addProperty("paused",Timer.prototype.getPaused,Timer.prototype.setPaused);
function formatTime(milliseconds){
var centiseconds = Math.floor(milliseconds/10);
var seconds = Math.floor(centiseconds/100);
var minutes = Math.floor(seconds/60);
centiseconds %= 0;
seconds %= 60;
minutes %= 60;
if (centiseconds < 10) centiseconds = "0" + centiseconds;
if (seconds < 10) seconds = "0" + seconds;
if (minutes < 10) minutes = "0" + minutes;
return minutes +":"+ seconds +""+ centiseconds;
}
var clock_timer = new Timer();
clock_timer.start();
this.onEnterFrame = function(){
display_txt.text = formatTime(clock_timer.time);
}
stop_btn.onRelease = function(){
clock_timer.stop();
}
play_btn.onRelease = function(){
if (clock_timer.paused) clock_timer.start(); // only start if paused
}
__________________
Синие теннисные мячики никогда не уронят своей чести... |
|
|||||
|
Guest
Сообщений: n/a
|
А вот моё скромное творение
![]() Код самого таймера (timer.swf) s=0;
//если время не равно нулю, можно подставить любое другое значение
m_time_txt.text = 0; //динамическое текстовое поля для минут
s_time_txt.text = 0; //для секунд
stop();
setInterval(function(){
if(_global.res_time){ //проверка запущен ли таймер
s++;
if((s/60) == 1)
{
s = 0;
m_time_txt.text = Number(m_time_txt.text)+1;
}
s_time_txt.text = s;
}
}
,1000)
;
this.createEmptyMovieClip("timer_place_mc",getNextHighestDepth()); //создает пустой клип для загрузки часов
this.timer_place_mc.loadMovie("timer.swf"); //загружает в него внешний swf-фильм с часами
this.timer_place_mc._x= 120; //позиционирует часы по оси Ох
this.timer_place_mc._y= 120; //позиционирует часы по оси Ох
_global.res_time = 1; //запускаем таймер, _global.res_time = 0; -остонавливает
setInterval(function(){ //..твоя функция..},time); где time - количество миллисекунд через которые нужно выполнять функцию, в данном случае 1000 (т.е. 1 секунда). Последний раз редактировалось Xero201; 14.10.2008 в 01:07. |
|
|||||
|
[+3 05.08.09]
Регистрация: Sep 2008
Адрес: Ё∙м∙с∙к
Сообщений: 147
|
!!!!!!!! спасибище! Всё работает!
(хотел сказать "как всё было просто", но пальцы не повернулись)
__________________
не прелюбодействуй с мозгом ближнего своего! |
![]() |
![]() |
Часовой пояс GMT +4, время: 08:59. |
|
|
« Предыдущая тема | Следующая тема » |
|
|