123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /*
- * Proxy
- * Visit http://createjs.com/ for documentation, updates and examples.
- *
- * Copyright (c) 2010 gskinner.com, inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
- /**
- * @module CreateJS
- */
- // namespace:
- this.createjs = this.createjs||{};
- /**
- * Various utilities that the CreateJS Suite uses. Utilities are created as separate files, and will be available on the
- * createjs namespace directly:
- *
- * <h4>Example</h4>
- * myObject.addEventListener("change", createjs.proxy(myMethod, scope));
- *
- * @class Utility Methods
- * @main Utility Methods
- */
- (function() {
- "use strict";
- /**
- * 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.
- *
- * <h4>Example</h4>
- * myObject.addEventListener("event", createjs.proxy(myHandler, this, arg1, arg2));
- *
- * function myHandler(arg1, arg2) {
- * // This gets called when myObject.myCallback is executed.
- * }
- *
- * @method proxy
- * @param {Function} method The function to call
- * @param {Object} scope The scope to call the method name on
- * @param {mixed} [arg] * Arguments that are appended to the callback for additional params.
- * @public
- * @static
- */
- createjs.proxy = function (method, scope) {
- var aArgs = Array.prototype.slice.call(arguments, 2);
- return function () {
- return method.apply(scope, Array.prototype.slice.call(arguments, 0).concat(aArgs));
- };
- }
- }());
|