API Documentation for: 0.5.2
Show:

Utility Methods Class

Defined in: Utility Methods:36
Module: CreateJS

Various utilities that the CreateJS Suite uses. Utilities are created as separate files, and will be available on the createjs namespace directly:

Example

 myObject.addEventListener("change", createjs.proxy(myMethod, scope));

Item Index

Methods

Methods

indexOf

(
  • array
  • searchElement
)
Number

Defined in indexOf:78

Finds the first occurrence of a specified value searchElement in the passed in array, and returns the index of that value. Returns -1 if value is not found.

 var i = createjs.indexOf(myArray, myElementToFind);

Parameters:

  • array Array

    Array to search for searchElement

  • searchElement Object

    Element to find in array.

Returns:

Number: The first index of searchElement in array.

proxy

(
  • method
  • scope
  • [arg]
)
public static

Defined in proxy:50

A function proxy for methods. By default, JavaScript methods do not maintain scope, so passing a method as a callback will result in the method getting called in the scope of the caller. Using a proxy ensures that the method gets called in the correct scope.

Additional arguments can be passed that will be applied to the function when it is called.

Example

 myObject.addEventListener("event", createjs.proxy(myHandler, this, arg1, arg2));

 function myHandler(arg1, arg2) {
      // This gets called when myObject.myCallback is executed.
 }

Parameters:

  • method Function

    The function to call

  • scope Object

    The scope to call the method name on

  • [arg] Mixed optional
    • Arguments that are appended to the callback for additional params.