@@ -44,7 +44,7 @@ this.createjs = this.createjs||{};
4444 *
4545 * function MySubClass() {}
4646 * createjs.extend(MySubClass, MySuperClass);
47- * ClassB .prototype.doSomething = function() { }
47+ * MySubClass .prototype.doSomething = function() { }
4848 *
4949 * var foo = new MySubClass();
5050 * console.log(foo instanceof MySuperClass); // true
@@ -271,12 +271,12 @@ this.createjs = this.createjs||{};
271271 * @deprecated
272272 */
273273 // p.initialize = function() {}; // searchable for devs wondering where it is.
274-
275274
276275// public methods:
277276 /**
278- * Sets {{#crossLink "Event/defaultPrevented"}}{{/crossLink}} to true.
279- * Mirrors the DOM event standard.
277+ * Sets {{#crossLink "Event/defaultPrevented"}}{{/crossLink}} to true if the event is cancelable.
278+ * Mirrors the DOM level 2 event standard. In general, cancelable events that have `preventDefault()` called will
279+ * cancel the default behaviour associated with the event.
280280 * @method preventDefault
281281 **/
282282 p . preventDefault = function ( ) {
@@ -404,7 +404,12 @@ this.createjs = this.createjs||{};
404404 * console.log(instance == this); // true, "on" uses dispatcher scope by default.
405405 * });
406406 *
407- * If you want to use addEventListener instead, you may want to use function.bind() or a similar proxy to manage scope.
407+ * If you want to use addEventListener instead, you may want to use function.bind() or a similar proxy to manage
408+ * scope.
409+ *
410+ * <b>Browser support</b>
411+ * The event model in CreateJS can be used separately from the suite in any project, however the inheritance model
412+ * requires modern browsers (IE9+).
408413 *
409414 *
410415 * @class EventDispatcher
@@ -507,7 +512,11 @@ this.createjs = this.createjs||{};
507512 * only run once, associate arbitrary data with the listener, and remove the listener.
508513 *
509514 * This method works by creating an anonymous wrapper function and subscribing it with addEventListener.
510- * The created anonymous function is returned for use with .removeEventListener (or .off).
515+ * The wrapper function is returned for use with `removeEventListener` (or `off`).
516+ *
517+ * <b>IMPORTANT:</b> To remove a listener added with `on`, you must pass in the returned wrapper function as the listener, or use
518+ * {{#crossLink "Event/remove"}}{{/crossLink}}. Likewise, each time you call `on` a NEW wrapper function is subscribed, so multiple calls
519+ * to `on` with the same params will create multiple listeners.
511520 *
512521 * <h4>Example</h4>
513522 *
@@ -577,6 +586,9 @@ this.createjs = this.createjs||{};
577586 /**
578587 * A shortcut to the removeEventListener method, with the same parameters and return value. This is a companion to the
579588 * .on method.
589+ *
590+ * <b>IMPORTANT:</b> To remove a listener added with `on`, you must pass in the returned wrapper function as the listener. See
591+ * {{#crossLink "EventDispatcher/on"}}{{/crossLink}} for an example.
580592 *
581593 * @method off
582594 * @param {String } type The string type of the event.
@@ -622,19 +634,24 @@ this.createjs = this.createjs||{};
622634 * @method dispatchEvent
623635 * @param {Object | String | Event } eventObj An object with a "type" property, or a string type.
624636 * While a generic object will work, it is recommended to use a CreateJS Event instance. If a string is used,
625- * dispatchEvent will construct an Event instance with the specified type.
626- * @return {Boolean } Returns the value of eventObj.defaultPrevented.
637+ * dispatchEvent will construct an Event instance if necessary with the specified type. This latter approach can
638+ * be used to avoid event object instantiation for non-bubbling events that may not have any listeners.
639+ * @param {Boolean } [bubbles] Specifies the `bubbles` value when a string was passed to eventObj.
640+ * @param {Boolean } [cancelable] Specifies the `cancelable` value when a string was passed to eventObj.
641+ * @return {Boolean } Returns false if `preventDefault()` was called on a cancelable event, true otherwise.
627642 **/
628- p . dispatchEvent = function ( eventObj ) {
643+ p . dispatchEvent = function ( eventObj , bubbles , cancelable ) {
629644 if ( typeof eventObj == "string" ) {
630- // won't bubble, so skip everything if there's no listeners:
645+ // skip everything if there's no listeners and it doesn't bubble :
631646 var listeners = this . _listeners ;
632- if ( ! listeners || ! listeners [ eventObj ] ) { return false ; }
633- eventObj = new createjs . Event ( eventObj ) ;
647+ if ( ! bubbles && ( ! listeners || ! listeners [ eventObj ] ) ) { return true ; }
648+ eventObj = new createjs . Event ( eventObj , bubbles , cancelable ) ;
634649 } else if ( eventObj . target && eventObj . clone ) {
635650 // redispatching an active event object, so clone it:
636651 eventObj = eventObj . clone ( ) ;
637652 }
653+
654+ // TODO: it would be nice to eliminate this. Maybe in favour of evtObj instanceof Event? Or !!evtObj.createEvent
638655 try { eventObj . target = this ; } catch ( e ) { } // try/catch allows redispatching of native events
639656
640657 if ( ! eventObj . bubbles || ! this . parent ) {
@@ -653,7 +670,7 @@ this.createjs = this.createjs||{};
653670 list [ i ] . _dispatchEvent ( eventObj , 3 ) ;
654671 }
655672 }
656- return eventObj . defaultPrevented ;
673+ return ! eventObj . defaultPrevented ;
657674 } ;
658675
659676 /**
@@ -1031,7 +1048,7 @@ this.createjs = this.createjs||{};
10311048 } ;
10321049
10331050 /**
1034- * Use the {{#crossLink "Ticker/framerate :property"}}{{/crossLink}} property instead.
1051+ * Use the {{#crossLink "Ticker/interval :property"}}{{/crossLink}} property instead.
10351052 * @method getInterval
10361053 * @static
10371054 * @return {Number }
@@ -1053,7 +1070,7 @@ this.createjs = this.createjs||{};
10531070 } ;
10541071
10551072 /**
1056- * Use the {{#crossLink "Ticker/interval :property"}}{{/crossLink}} property instead.
1073+ * Use the {{#crossLink "Ticker/framerate :property"}}{{/crossLink}} property instead.
10571074 * @method getFPS
10581075 * @static
10591076 * @return {Number }
@@ -1205,7 +1222,8 @@ this.createjs = this.createjs||{};
12051222 } ;
12061223
12071224 /**
1208- * Similar to getTime(), but returns the time on the most recent tick event object.
1225+ * Similar to the {{#crossLink "Ticker/getTime"}}{{/crossLink}} method, but returns the time on the most recent {{#crossLink "Ticker/tick:event"}}{{/crossLink}}
1226+ * event object.
12091227 * @method getEventTime
12101228 * @static
12111229 * @param runTime {Boolean} [runTime=false] If true, the runTime property will be returned instead of time.
@@ -3324,7 +3342,7 @@ this.createjs = this.createjs||{};
33243342 * @static
33253343 */
33263344 MotionGuidePlugin . calc = function ( data , ratio , target ) {
3327- if ( data . _segments == undefined ) { MotionGuidePlugin . validate ( data ) ; }
3345+ if ( data . _segments == undefined ) { throw ( "Missing critical pre-calculated information, please file a bug" ) ; }
33283346 if ( target == undefined ) { target = { x :0 , y :0 , rotation :0 } ; }
33293347 var seg = data . _segments ;
33303348 var path = data . path ;
@@ -3398,6 +3416,6 @@ this.createjs = this.createjs || {};
33983416 * @type String
33993417 * @static
34003418 **/
3401- s . buildDate = /*=date*/ "Wed, 27 May 2015 18:12:44 GMT" ; // injected by build process
3419+ s . buildDate = /*=date*/ "Wed, 25 Nov 2015 19:32:49 GMT" ; // injected by build process
34023420
34033421} ) ( ) ;
0 commit comments