2010-02-21 186 views
0

嗨我想每2.5秒闪烁一次光标,但我不知道如何使用SC.Timer对象....我应该调用的方法是每隔_drawInsertionPoint(rect,context) 2.5秒....使用SC.Timer闪烁光标

我发现这个

var timer = SC.Timer.schedule({ 
target: this 
action: '_drawInsertionPoint(rec,context)', 
interval: 100, 
repeats: YES, 
until: Time.now() + 1000 
}) ; 

但我不知道如何在工作中的参数传递...它不会工作

任何有识之士这将是非常感谢...

感谢

回答

1

你需要传递一个匿名函数作为action参数,就像这样:

var timer = SC.Timer.schedule({ 
    target: this 
    action: function() { _drawInsertionPoint(rec,context); }, 
    interval: 100, 
    repeats: YES, 
    until: Time.now() + 1000 
}); 
+0

,我怎么能叫这还是它会自动被调用 – Rob 2010-02-21 22:14:18

+0

它的工作方式与你的代码相同,但而不是评估字符串,计时器将调用该函数。 – SLaks 2010-02-21 22:19:52