2011-05-07 82 views

回答

1

的問題是,recurTime參數TimerManager.start是正常參數的正常功能,所以只計算一次當函數被調用。這不是一個反覆重新評估的表達式。這意味着你只能通過TimerManager獲得等距執行。

您可能需要手工編寫您想要的代碼,例如,使用qx.event.Timer.once每次調用重新計算一次超時。

編輯:

下面的代碼片段,可能走在正確的方向你(這將在類的Qooxdoo的情況下工作):

var that = this; 
function doStuff(timeout) { 
    // do the things here you want to do in every timeout 
    // this example just logs the new calculated time offset 
    that.debug(timeout); 
} 

function callBack() { 
    // this just calls doStuff and handles a new time offset 
    var timeout = (Math.floor(Math.random()*11)*1000) + 5000; 
    doStuff(timeout); 
    qx.event.Timer.once(callBack, that, timeout); 
} 

// fire off the first execution 
qx.event.Timer.once(callBack, that, 5000);