setTimeout()
The same as window.setTimeout()
except that the supplied
method is bound to the calling behavior object.
Syntax
behavior.setTimeout(method [, delay [, arg1, arg2, ..., argN]]);
The method argument may also be a string identifying the method by name.
If the delay argument is not supplied then it defaults to 1
(milliseconds).
Arguments supplied after the delay argument are passed to the bound method.
Example
var mybehavior = jsb.behavior.extend({ onmouseover: function(element) { // show a tooltip after 1 second this._timer = this.setTimeout(this.showHint, 1000, element, "Click to hide."); }, onmouseout: function(element) { clearTimeout(this._timer); delete this._timer; }, showHint: function(element, text) { var offset = this.getOffsetFromBody(element); var tooltip = new ToolTip(text); tooltip.show(offset.left + 10, offset.top + 10); } });
Notes
There is no jsb-equivalent clearTimeout()
method. Instead, you should
use the global clearTimeout()
method.