API Document Index



Built-In Namespace Function

Method Summary
Method Attributes Method Name and Description
 
bind(context, args)
ensure bind is properly supported
(c) Prototype.js

Binds this function to the given context by wrapping it in another function and returning the wrapper.

 
Executes a function as soon as the interpreter is idle (stack empty).
Method Detail
bind(context, args)
ensure bind is properly supported
(c) Prototype.js

Binds this function to the given context by wrapping it in another function and returning the wrapper.

Whenever the resulting "bound" function is called, it will call the original ensuring that this is set to context.

Also optionally curries arguments for the function.
Defined in: <build/melonJS-0.9.3.js>.

// A typical use of Function bind is to ensure that a callback
// (event handler, etc.) that is an object method gets called with 
// the correct object as its context (this value):

// -> WRONG
myObject.onComplete(this.callback);

// -> RIGHT 
myObject.onComplete(this.callback.bind(this));
Parameters:
{Object} context
the object to bind to.
{Array.} args Optional
Optional additional arguments to curry for the function.

defer()
Executes a function as soon as the interpreter is idle (stack empty).
Defined in: <build/melonJS-0.9.3.js>.
  // execute myFunc() when the stack is empty, with 'myArgument' as parameter
  myFunc.defer('myArgument');
Returns:
id that can be used to clear the deferred function using clearTimeout

Documentation generated by JsDoc Toolkit 2.4.0 on Tue May 01 2012 12:00:48 GMT+0800 (CST)