2009-07-07 11 views

答えて

2

正しく機能していないのは、MooTools documentationです。あなたの例では

、あなたは一度関数を実行し、(それゆえ、あなたの最初のメッセージが1000msでは遅らせない後、直接記録されます)、それの戻り値に定期的な機能を使用しよう:

var Main = new Class({ 
    Implements: [Options], 

    options: { 
    releaseDate: '1 January, 2010' 
    }, 

    initialize: function(options){ 
    this.setOptions(options); 
    this.startClock(); 
    }, 

    startClock: function(){ 
    var current = $time(); 
    var future = new Date(this.options.releaseDate); 
    future = future.getTime(); 

    this.clock = this.iterateClock(current, future).periodical(1000, this); 
    }, 

    iterateClock: function(current, future){ 
    var difference = future - current; 

    var days = Math.floor((difference/(60 * 60 * 24))/1000); 
    console.log(days); 
    } 
}); 

あなたが欲しいです指定された期間、バインディングと引数(配列として)を指定してiterateClock関数を定期的に呼び出します。

this.clock = this.iterateClock.periodical(1000, this, [current, future]); 
+0

mootoolsのメールリストで同じ回答を得ました。これを解決する別の方法は、anon関数をクロージャとして使用し、元のコードと同じように定期的に適用することです。 –

関連する問題