1 /** 2 * The MIT License (MIT) 3 * 4 * Copyright (c) 2016 DeNA Co., Ltd. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 * SOFTWARE. 23 */ 24 25 /// <reference path="base.js"/> 26 /// <reference path="event_dispatcher.js"/> 27 /// <reference path="object_list"/> 28 /// <reference path="point.js"/> 29 /// <reference path="color.js"/> 30 /// <reference path="rectangle.js"/> 31 /// <reference path="bounding_box.js"/> 32 /// <reference path="transform.js"/> 33 /// <reference path="filter.js"/> 34 /// <reference path="shadow.js"/> 35 /// <reference path="renderer.js"/> 36 /// <reference path="tween_object.js"/> 37 /// <reference path="tween_target.js"/> 38 /// <reference path="ticker.js"/> 39 /// <reference path="alpha_map_filter.js"/> 40 /// <reference path="color_filter.js"/> 41 /// <reference path="color_matrix_filter.js"/> 42 43 /** 44 * A base class for all drawable objects. This class consists of five 45 * functionalities listed below: 46 * 1. Implementing external methods used by games; 47 * 2. Implementing getters and setters to monitor the properties changed by 48 * games; 49 * 3. Implementing an interface used for rendering an object; 50 * 4. Implementing an interface used by a tween to change the properties of this 51 * object, and; 52 * 5. Updating tweens attached to this object. 53 * A display object updates its tweens when its target is being rendered not 54 * only because it can monitor property changes to it but also because it can 55 * update a tween only once/frame.) 56 * @extends {createjs.EventDispatcher} 57 * @implements {createjs.Renderer.RenderObject} 58 * @implements {createjs.TweenTarget} 59 * @constructor 60 */ 61 createjs.DisplayObject = function() { 62 createjs.EventDispatcher.call(this); 63 64 if (createjs.DEBUG) { 65 /** 66 * The Unique ID assigned to this display object. 67 * @type {number} 68 */ 69 this.id = createjs.UID.get(); 70 } 71 72 /** 73 * The rendering state of this object, a set of the variables having used by 74 * the createjs.Renderer interface to render this object. 75 * @type {createjs.DisplayObject.RenderState} 76 * @private 77 */ 78 this.state_ = new createjs.DisplayObject.RenderState(); 79 80 /** 81 * The position of this display object. 82 * @type {createjs.Point} 83 * @private 84 */ 85 this.position_ = new createjs.Point(0, 0); 86 87 /** 88 * The scaling factor to stretch this display object. 89 * @type {createjs.Point} 90 * @private 91 */ 92 this.scale_ = new createjs.Point(1, 1); 93 94 /** 95 * The factor to skew this display object. 96 * @type {createjs.Point} 97 * @private 98 */ 99 this.skew_ = new createjs.Point(0, 0); 100 101 /** 102 * The registration point of this display object. 103 * @type {createjs.Point} 104 * @private 105 */ 106 this.registration_ = new createjs.Point(0, 0); 107 108 /** 109 * The bounding box of this object in the local coordinate system. (The 110 * createjs.DisplayObject.RenderState class translates this box to the global 111 * coordinate system.) 112 * @type {createjs.BoundingBox} 113 * @private 114 */ 115 this.box_ = new createjs.BoundingBox(); 116 }; 117 createjs.inherits('DisplayObject', 118 createjs.DisplayObject, 119 createjs.EventDispatcher); 120 121 /** 122 * The inner class that controls the tweens attached to this object. 123 * @extends {createjs.ObjectList} 124 * @constructor 125 */ 126 createjs.DisplayObject.ObjectList = function() { 127 createjs.ObjectList.call(this); 128 }; 129 createjs.inherits('DisplayObject.ObjectList', 130 createjs.DisplayObject.ObjectList, 131 createjs.ObjectList); 132 133 /** 134 * The next position of the tweens in this list. This property saves the 135 * position set by an action while this clip while it is updating its tweens. 136 * @type {number} 137 * @private 138 */ 139 createjs.DisplayObject.ObjectList.prototype.next_ = -1; 140 141 /** 142 * The last time when the owner object updates this list. 143 * @type {number} 144 * @private 145 */ 146 createjs.DisplayObject.ObjectList.prototype.lastTime_ = -1; 147 148 /** 149 * Starts playing the tweens in this target. 150 * @param {number} time 151 * @private 152 */ 153 createjs.DisplayObject.ObjectList.prototype.playTweens_ = function(time) { 154 /// <param type="number" name="time"/> 155 var tweens = /** @type {Array.<createjs.TweenObject>} */ (this.getItems()); 156 var length = tweens.length; 157 for (var i = length - 1; i >= 0; --i) { 158 tweens[i].playTween(time); 159 } 160 }; 161 162 /** 163 * Stops playing the tweens in this target. 164 * @param {number} time 165 * @private 166 */ 167 createjs.DisplayObject.ObjectList.prototype.stopTweens_ = function(time) { 168 /// <param type="number" name="time"/> 169 var tweens = /** @type {Array.<createjs.TweenObject>} */ (this.getItems()); 170 var length = tweens.length; 171 for (var i = length - 1; i >= 0; --i) { 172 tweens[i].stopTween(time); 173 } 174 }; 175 176 /** 177 * Updates the tweens in this list. 178 * @param {number} time 179 * @param {number} flag 180 * @return {number} 181 */ 182 createjs.DisplayObject.ObjectList.prototype.updateTweens_ = 183 function(time, flag) { 184 /// <param type="number" name="time"/> 185 /// <param type="number" name="flag"/> 186 /// <returns type="number"/> 187 var tweens = /** @type {Array.<createjs.TweenObject>} */ (this.lock()); 188 var length = tweens.length; 189 createjs.assert(length > 0); 190 var position = -1; 191 if (this.next_ >= 0 && flag == createjs.TweenTarget.PlayMode.SYNCHED) { 192 flag |= createjs.TweenObject.Flag.UPDATE; 193 } 194 for (var i = length - 1; i >= 0; --i) { 195 var next = this.next_; 196 position = tweens[i].updateTween(time, flag, this.next_); 197 // Change the position of the proceeding tweens when an action of the above 198 // tween has changed the position of all tweens of this list. (The 199 // succeeding updateTween() calls will change the position of all succeeding 200 // tweens to the specified one.) 201 if (this.next_ != next) { 202 flag |= createjs.TweenObject.Flag.UPDATE; 203 for (var j = length - 1; j >= i; --j) { 204 tweens[j].setPosition(this.next_, 1); 205 } 206 } 207 } 208 this.unlock(); 209 this.next_ = -1; 210 this.lastTime_ = time; 211 return position; 212 }; 213 214 /** 215 * Sets the play offsets of all tweens in this list. 216 * @param {number} time 217 * @param {number} position 218 * @param {boolean} paused 219 * @private 220 */ 221 createjs.DisplayObject.ObjectList.prototype.setPositions_ = 222 function(time, position, paused) { 223 /// <param type="number" name="time"/> 224 /// <param type="number" name="position"/> 225 /// <param type="boolean" name="paused"/> 226 if (this.isLocked() || (!paused && this.lastTime_ < time)) { 227 // Save the given position when this list is being updated so the 228 // 'updateTween()' method can use this position. 229 this.next_ = position; 230 return; 231 } 232 var tweens = /** @type {Array.<createjs.TweenObject>} */ (this.getItems()); 233 var length = tweens.length; 234 for (var i = length - 1; i >= 0; --i) { 235 tweens[i].setPosition(position, 1); 236 } 237 // Discard the position set by a startPosition property when a gotoAndPlay() 238 // call changes it. 239 this.next_ = -1; 240 }; 241 242 /** 243 * Sets the play offsets of all tweens in this list. 244 * @param {createjs.TweenTarget} target 245 * @param {boolean} loop 246 * @param {number} position 247 * @param {boolean} single 248 * @private 249 */ 250 createjs.DisplayObject.ObjectList.prototype.setProperties_ = 251 function(target, loop, position, single) { 252 /// <param type="boolean" name="loop"/> 253 /// <param type="number" name="position"/> 254 /// <param type="boolean" name="single"/> 255 var tweens = /** @type {Array.<createjs.TweenObject>} */ (this.getItems()); 256 var length = tweens.length; 257 for (var i = length - 1; i >= 0; --i) { 258 tweens[i].setProperties(loop, position, single); 259 } 260 // Save the given position to change the positions of its tweens when this 261 // object updates them. (A movie clip updates its tweens immediately after 262 // returning from this method.) 263 this.next_ = position; 264 }; 265 266 /** 267 * An inner class that represents properties used for rendering a DisplayObject 268 * object. This class consists of an affine transform, display properties, and a 269 * bounding box. 270 * @extends {createjs.Transform} 271 * @constructor 272 */ 273 createjs.DisplayObject.RenderState = function() { 274 createjs.Transform.call(this); 275 276 /** 277 * The bounding box of the owner. This bounding box is in the <canvas> 278 * coordinate. 279 * @type {createjs.BoundingBox} 280 * @private 281 */ 282 this.box_ = new createjs.BoundingBox(); 283 }; 284 createjs.inherits('DisplayObject.RenderState', 285 createjs.DisplayObject.RenderState, 286 createjs.Transform); 287 288 /** 289 * The absolute alpha transparency, i.e. an alpha transparency multiplied with 290 * the ancestor ones. 291 * @type {number} 292 * @private 293 */ 294 createjs.DisplayObject.RenderState.prototype.alpha_ = 1; 295 296 /** 297 * The shadow applied to the owner. 298 * @type {createjs.Shadow} 299 * @private 300 */ 301 createjs.DisplayObject.RenderState.prototype.shadow_ = null; 302 303 /** 304 * The color composition applied to the owner. 305 * @type {number} 306 * @private 307 */ 308 createjs.DisplayObject.RenderState.prototype.composition_ = 309 createjs.Renderer.Composition.SOURCE_OVER; 310 311 /** 312 * The mask applied to the owner. 313 * @type {createjs.Renderer.Clip} 314 * @private 315 */ 316 createjs.DisplayObject.RenderState.prototype.clip_ = null; 317 318 /** 319 * Retrieves the clipping information. 320 * @return {createjs.Renderer.Clip} 321 * @const 322 */ 323 createjs.DisplayObject.RenderState.prototype.getClip = function() { 324 /// <returns type="createjs.Renderer.Clip"/> 325 return this.clip_; 326 }; 327 328 /** 329 * Retrieves the alpha transparency. 330 * @return {number} 331 * @const 332 */ 333 createjs.DisplayObject.RenderState.prototype.getAlpha = function() { 334 /// <returns type="number"/> 335 return this.alpha_; 336 }; 337 338 /** 339 * Retrieves the bounding box. 340 * @return {createjs.BoundingBox} 341 * @const 342 */ 343 createjs.DisplayObject.RenderState.prototype.getBox = function() { 344 /// <returns type="createjs.BoundingBox"/> 345 return this.clip_ ? this.clip_.getBox() : this.box_; 346 }; 347 348 /** 349 * Resets the bounding box. 350 * @const 351 */ 352 createjs.DisplayObject.RenderState.prototype.resetBox = function() { 353 this.box_.reset(); 354 }; 355 356 /** 357 * Retrieves the shadow. 358 * @return {createjs.Shadow} 359 * @const 360 */ 361 createjs.DisplayObject.RenderState.prototype.getShadow = function() { 362 /// <returns type="createjs.Shadow"/> 363 return this.shadow_; 364 }; 365 366 /** 367 * Returns whether this state represents an empty state, i.e. the hosting 368 * display object is not 369 * createjs.Renderer objects cannot render the hosting display object. 370 * @return {boolean} 371 * @const 372 */ 373 createjs.DisplayObject.RenderState.prototype.isEmpty = function() { 374 /// <returns type="boolean"/> 375 return this.box_.isEmpty(); 376 }; 377 378 /** 379 * Returns whether this state contains the specified point. 380 * @param {createjs.Point} point 381 * @return {boolean} 382 * @const 383 */ 384 createjs.DisplayObject.RenderState.prototype.contain = function(point) { 385 /// <returns type="createjs.Point"/> 386 return this.box_.contain(point.x, point.y); 387 }; 388 389 /** 390 * Copies the specified rendering property to this property. 391 * @param {createjs.DisplayObject.RenderState} state 392 * @const 393 */ 394 createjs.DisplayObject.RenderState.prototype.copyProperties = function(state) { 395 /// <param type="createjs.DisplayObject.RenderState" name="state"/> 396 this.alpha_ = state.alpha_; 397 this.shadow_ = state.shadow_; 398 this.composition_ = state.composition_; 399 }; 400 401 /** 402 * Appends the specified visual properties to this state. 403 * @param {createjs.DisplayObject.RenderState} state 404 * @param {number} alpha 405 * @param {createjs.Shadow} shadow 406 * @param {number} composition 407 * @param {boolean} visible 408 * @const 409 */ 410 createjs.DisplayObject.RenderState.prototype.appendProperties = 411 function(state, alpha, shadow, composition, visible) { 412 /// <param type="createjs.DisplayObject.RenderState" name="state"/> 413 /// <param type="number" name="alpha"/> 414 /// <param type="createjs.Shadow" name="shadow"/> 415 /// <param type="number" name="composition"/> 416 /// <param type="boolean" name="visible"/> 417 this.alpha_ = state.alpha_ * alpha; 418 this.shadow_ = shadow || state.shadow_; 419 this.composition_ = composition || state.composition_; 420 }; 421 422 /** 423 * Attaches the specified clipping object to this state. 424 * @param {createjs.DisplayObject.RenderState} state 425 * @param {createjs.Renderer.Clip} clip 426 * @const 427 */ 428 createjs.DisplayObject.RenderState.prototype.appendClip = 429 function(state, clip) { 430 this.clip_ = state.clip_ || clip; 431 }; 432 433 /** 434 * Transforms a bounding box in the local coordinate system of the owner object 435 * to a box in the global coordinate system, which is used by the 436 * createjs.Renderer interface. 437 * @param {createjs.BoundingBox} box 438 * @const 439 */ 440 createjs.DisplayObject.RenderState.prototype.updateBox = function(box) { 441 /// <param type="createjs.BoundingBox" name="box"/> 442 this.transformBox(box, this.box_); 443 }; 444 445 /** 446 * Inflates the bounding box of this rendering state by the one of the specified 447 * state. 448 * @param {createjs.DisplayObject.RenderState} state 449 * @const 450 */ 451 createjs.DisplayObject.RenderState.prototype.inflateBox = function(state) { 452 /// <param type="createjs.DisplayObject.RenderState" name="state"/> 453 this.box_.inflate(state.getBox()); 454 }; 455 456 /** 457 * Returns whether this state represents a visible state. 458 * @return {boolean} 459 * @const 460 */ 461 createjs.DisplayObject.RenderState.prototype.isVisible = function() { 462 /// <returns type="boolean"/> 463 return this.alpha_ > 0; 464 }; 465 466 /** 467 * A flag representing that this object needs to update its affine 468 * transformation. 469 * @const {number} 470 * @protected 471 */ 472 createjs.DisplayObject.DIRTY_TRANSFORM = (1 << 0) | (1 << 3); 473 474 /** 475 * A flag representing that this object needs to update its attributes. 476 * @const {number} 477 * @protected 478 */ 479 createjs.DisplayObject.DIRTY_PROPERTIES = 1 << 1; 480 481 /** 482 * A flag representing that this object needs to update its shape. 483 * @const {number} 484 * @protected 485 */ 486 createjs.DisplayObject.DIRTY_SHAPE = 1 << 2; 487 488 /** 489 * A flag representing that this object needs to update its mask. 490 * @const {number} 491 * @protected 492 */ 493 createjs.DisplayObject.DIRTY_MASK = 1 << 3; 494 495 /** 496 * A flag representing that this object needs to update its bounding box. 497 * @const {number} 498 * @protected 499 */ 500 createjs.DisplayObject.DIRTY_BOX = 1 << 4; 501 502 /** 503 * A flag representing that this object needs to update all its properties. 504 * @const {number} 505 * @protected 506 */ 507 createjs.DisplayObject.DIRTY_ALL = createjs.DisplayObject.DIRTY_TRANSFORM | 508 createjs.DisplayObject.DIRTY_PROPERTIES | 509 createjs.DisplayObject.DIRTY_SHAPE | 510 createjs.DisplayObject.DIRTY_BOX; 511 512 /** 513 * Whether this display object should be removed from an object tree. This 514 * value is used by tweens to remove a display object. 515 * @type {boolean} 516 */ 517 createjs.DisplayObject.prototype['_off'] = false; 518 519 /** 520 * The name of this object. The createjs.Container.prototype.getChildByName() 521 * uses this property to find display objects. 522 * @type {string} 523 */ 524 createjs.DisplayObject.prototype['name'] = ''; 525 526 if (createjs.DEBUG) { 527 /** 528 * The unique ID assigned to this object. 529 * @type {number} 530 * @protected 531 */ 532 createjs.DisplayObject.prototype.id = -1; 533 } 534 535 /** 536 * A dirty flag, i.e. a flag representing variables that should be re-calculated 537 * before a createjs.Renderer object renders this object. 538 * @type {number} 539 * @protected 540 */ 541 createjs.DisplayObject.prototype.dirty = 0; 542 543 /** 544 * Whether this object is a 'createjs.Stage' object. 545 * @type {boolean} 546 * @protected 547 */ 548 createjs.DisplayObject.prototype.isStage = false; 549 550 /** 551 * The rotation in degrees for this display object. 552 * @type {number} 553 * @private 554 */ 555 createjs.DisplayObject.prototype.rotation_ = 0; 556 557 /** 558 * Whether this display object should be rendered. 559 * @type {boolean} 560 * @private 561 */ 562 createjs.DisplayObject.prototype.visible_ = true; 563 564 /** 565 * The alpha (transparency) value of this display object. 566 * @type {number} 567 * @private 568 */ 569 createjs.DisplayObject.prototype.alpha_ = 1; 570 571 /** 572 * The composite operation used in rendering this object. 573 * @type {number} 574 * @private 575 */ 576 createjs.DisplayObject.prototype.composition_ = 577 createjs.Renderer.Composition.SOURCE_OVER; 578 579 /** 580 * A shadow to render on this display object. 581 * @type {createjs.Shadow} 582 * @private 583 */ 584 createjs.DisplayObject.prototype.shadow_ = null; 585 586 /** 587 * A clipping path for this object. 588 * @type {createjs.DisplayObject} 589 * @private 590 */ 591 createjs.DisplayObject.prototype.mask_ = null; 592 593 /** 594 * A display object that owns this mask object if this object is a mask. 595 * @type {Array.<createjs.DisplayObject>} 596 * @private 597 */ 598 createjs.DisplayObject.prototype.owners_ = null; 599 600 /** 601 * An inverse Affine transformation used for transforming a point in the local 602 * coordinate system to a point in the global coordinate system. 603 * @type {createjs.Transform} 604 * @private 605 */ 606 createjs.DisplayObject.prototype.inverse_ = null; 607 608 /** 609 * The clipping rectangle of the mask in the global coordinate system. 610 * @type {createjs.Renderer.Clip} 611 * @private 612 */ 613 createjs.DisplayObject.prototype.clip_ = null; 614 615 /** 616 * The color multiplier used for composing this object. 617 * @type {Array.<number>} 618 * @private 619 */ 620 createjs.DisplayObject.prototype.colorMatrix_ = null; 621 622 /** 623 * The alpha map used for composing this object. 624 * @type {createjs.AlphaMapFilter} 625 * @private 626 */ 627 createjs.DisplayObject.prototype.alphaMapFilter_ = null; 628 629 /** 630 * A list of tweens attached to this object. 631 * @type {createjs.DisplayObject.ObjectList} 632 * @private 633 */ 634 createjs.DisplayObject.prototype.tweens_ = null; 635 636 /** 637 * Whether this object is playing its tweens or its sprite sheet. 638 * @type {boolean} 639 * @private 640 */ 641 createjs.DisplayObject.prototype.paused_ = false; 642 643 /** 644 * Whether this object is changing the position of its tweens. 645 * @type {boolean} 646 * @private 647 */ 648 createjs.DisplayObject.prototype.seek_ = false; 649 650 /** 651 * The current position of the tweens attached to this object. 652 * @type {number} 653 * @private 654 */ 655 createjs.DisplayObject.prototype.currentFrame_ = -1; 656 657 /** 658 * The play mode of the tweens attached to this object. 659 * @type {number} 660 * @private 661 */ 662 createjs.DisplayObject.prototype.playMode_ = 663 createjs.TweenTarget.PlayMode.INDEPENDENT; 664 665 /** 666 * A list of tween targets synchronized with this object. 667 * @type {Array.<createjs.TweenTarget>} 668 * @private 669 */ 670 createjs.DisplayObject.prototype.synchronized_ = null; 671 672 /** 673 * A rectangle used by the getBounds() method. 674 * @type {createjs.Rectangle} 675 * @private 676 */ 677 createjs.DisplayObject.prototype.rectangle_ = null; 678 679 /** 680 * Updates the clipping rectangle of this object. 681 * @param {createjs.DisplayObject} parent 682 * @private 683 */ 684 createjs.DisplayObject.prototype.updateClip_ = function(parent) { 685 /// <param type="createjs.DisplayObject" name="parent"/> 686 var mask = this.mask_; 687 mask.updateLayout(parent, createjs.DisplayObject.DIRTY_TRANSFORM); 688 mask.state_.updateBox(mask.box_); 689 this.clip_ = new createjs.Renderer.Clip( 690 mask.state_, 691 mask.box_, 692 mask.state_.box_, 693 mask.composition_, 694 this.composition_, 695 mask); 696 }; 697 698 /** 699 * Returns the dirty state of this object. 700 * @return {number} 701 * @protected 702 * @const 703 */ 704 createjs.DisplayObject.prototype.getDirty = function() { 705 /// <returns type="number"/> 706 return this.dirty; 707 }; 708 709 /** 710 * Sets the dirty state of this object. 711 * @param {number} dirty 712 * @protected 713 * @const 714 */ 715 createjs.DisplayObject.prototype.setDirty = function(dirty) { 716 /// <param type="number" name="dirty"/> 717 this.dirty |= dirty; 718 }; 719 720 /** 721 * A rectangle automatically generated by Flash. Even though this library does 722 * not use this rectangle, we add its placeholder to prevent Flash from 723 * extending the DisplayObject object. 724 * @type {createjs.Rectangle} 725 */ 726 createjs.DisplayObject.prototype.nominalBounds = null; 727 728 /** 729 * Retrieves the horizontal position. 730 * @return {number} 731 * @const 732 */ 733 createjs.DisplayObject.prototype.getX = function() { 734 /// <returns type="number"/> 735 return this.position_.x; 736 }; 737 738 /** 739 * Sets the horizontal position. 740 * @param {number} x 741 * @const 742 */ 743 createjs.DisplayObject.prototype.setX = function(x) { 744 /// <param type="number" name="x"/> 745 x = createjs.getNumber(x); 746 if (!createjs.isNaN(x) && this.position_.x != x) { 747 this.position_.x = x; 748 this.setDirty(createjs.DisplayObject.DIRTY_TRANSFORM); 749 } 750 }; 751 752 /** 753 * Retrieves the vertical position. 754 * @return {number} 755 * @const 756 */ 757 createjs.DisplayObject.prototype.getY = function() { 758 /// <returns type="number"/> 759 return this.position_.y; 760 }; 761 762 /** 763 * Sets the vertical position. 764 * @param {number} y 765 * @const 766 */ 767 createjs.DisplayObject.prototype.setY = function(y) { 768 /// <param type="number" name="y"/> 769 y = createjs.getNumber(y); 770 if (!createjs.isNaN(y) && this.position_.y != y) { 771 this.position_.y = y; 772 this.setDirty(createjs.DisplayObject.DIRTY_TRANSFORM); 773 } 774 }; 775 776 /** 777 * Retrieves the horizontal scale. 778 * @return {number} 779 * @const 780 */ 781 createjs.DisplayObject.prototype.getScaleX = function() { 782 /// <returns type="number"/> 783 return this.scale_.x; 784 }; 785 786 /** 787 * Sets the horizontal scale. 788 * @param {number} scaleX 789 * @const 790 */ 791 createjs.DisplayObject.prototype.setScaleX = function(scaleX) { 792 /// <param type="number" name="scaleX"/> 793 scaleX = createjs.getNumber(scaleX); 794 if (this.scale_.x != scaleX) { 795 this.scale_.x = scaleX; 796 this.setDirty(createjs.DisplayObject.DIRTY_TRANSFORM); 797 } 798 }; 799 800 /** 801 * Retrieves the vertical scale. 802 * @return {number} 803 * @const 804 */ 805 createjs.DisplayObject.prototype.getScaleY = function() { 806 /// <returns type="number"/> 807 return this.scale_.y; 808 }; 809 810 /** 811 * Sets the vertical scale. 812 * @param {number} scaleY 813 * @const 814 */ 815 createjs.DisplayObject.prototype.setScaleY = function(scaleY) { 816 /// <param type="number" name="scaleY"/> 817 scaleY = createjs.getNumber(scaleY); 818 if (this.scale_.y != scaleY) { 819 this.scale_.y = scaleY; 820 this.setDirty(createjs.DisplayObject.DIRTY_TRANSFORM); 821 } 822 }; 823 824 /** 825 * Retrieves the horizontal skew. 826 * @return {number} 827 * @const 828 */ 829 createjs.DisplayObject.prototype.getSkewX = function() { 830 /// <returns type="number"/> 831 return this.skew_.x; 832 }; 833 834 /** 835 * Sets the horizontal skew. 836 * @param {number} skewX 837 * @const 838 */ 839 createjs.DisplayObject.prototype.setSkewX = function(skewX) { 840 /// <param type="number" name="skewX"/> 841 skewX = createjs.getNumber(skewX); 842 if (this.skew_.x != skewX) { 843 this.skew_.x = skewX; 844 this.setDirty(createjs.DisplayObject.DIRTY_TRANSFORM); 845 } 846 }; 847 848 /** 849 * Retrieves the vertical skew. 850 * @return {number} 851 * @const 852 */ 853 createjs.DisplayObject.prototype.getSkewY = function() { 854 /// <returns type="number"/> 855 return this.skew_.y; 856 }; 857 858 /** 859 * Sets the vertical skew. 860 * @param {number} skewY 861 * @const 862 */ 863 createjs.DisplayObject.prototype.setSkewY = function(skewY) { 864 /// <param type="number" name="skewY"/> 865 skewY = createjs.getNumber(skewY); 866 if (this.skew_.y != skewY) { 867 this.skew_.y = skewY; 868 this.setDirty(createjs.DisplayObject.DIRTY_TRANSFORM); 869 } 870 }; 871 872 /** 873 * Retrieves the horizontal registration point. 874 * @return {number} 875 * @const 876 */ 877 createjs.DisplayObject.prototype.getRegX = function() { 878 /// <returns type="number"/> 879 return this.registration_.x; 880 }; 881 882 /** 883 * Sets the horizontal registration point. 884 * @param {number} regX 885 * @const 886 */ 887 createjs.DisplayObject.prototype.setRegX = function(regX) { 888 /// <param type="number" name="regX"/> 889 regX = createjs.getNumber(regX); 890 if (this.registration_.x != regX) { 891 this.registration_.x = regX; 892 this.setDirty(createjs.DisplayObject.DIRTY_TRANSFORM); 893 } 894 }; 895 896 /** 897 * Retrieves the vertical registration point. 898 * @return {number} 899 * @const 900 */ 901 createjs.DisplayObject.prototype.getRegY = function() { 902 /// <returns type="number"/> 903 return this.registration_.y; 904 }; 905 906 /** 907 * Sets the vertical registration point. 908 * @param {number} regY 909 * @const 910 */ 911 createjs.DisplayObject.prototype.setRegY = function(regY) { 912 /// <param type="number" name="regY"/> 913 regY = createjs.getNumber(regY); 914 if (this.registration_.y != regY) { 915 this.registration_.y = regY; 916 this.setDirty(createjs.DisplayObject.DIRTY_TRANSFORM); 917 } 918 }; 919 920 /** 921 * Retrieves the rotation. 922 * @return {number} 923 * @const 924 */ 925 createjs.DisplayObject.prototype.getRotation = function() { 926 /// <returns type="number"/> 927 return this.rotation_; 928 }; 929 930 /** 931 * Sets the rotation. 932 * @param {number} rotation 933 * @const 934 */ 935 createjs.DisplayObject.prototype.setRotation = function(rotation) { 936 /// <param type="number" name="rotation"/> 937 rotation = createjs.getNumber(rotation); 938 if (this.rotation_ != rotation) { 939 this.rotation_ = rotation; 940 this.setDirty(createjs.DisplayObject.DIRTY_TRANSFORM); 941 } 942 }; 943 944 /** 945 * Retrieves the visibility. 946 * @return {boolean} 947 * @const 948 */ 949 createjs.DisplayObject.prototype.getVisible = function() { 950 /// <returns type="boolean"/> 951 return this.visible_; 952 }; 953 954 /** 955 * Sets the visibility. 956 * @param {boolean} visible 957 * @const 958 */ 959 createjs.DisplayObject.prototype.setVisible = function(visible) { 960 /// <param type="boolean" name="visible"/> 961 visible = !!visible; 962 if (this.visible_ != visible) { 963 this.visible_ = visible; 964 this.setDirty(createjs.DisplayObject.DIRTY_ALL); 965 } 966 }; 967 968 /** 969 * Retrieves the alpha value. 970 * @return {number} 971 * @const 972 */ 973 createjs.DisplayObject.prototype.getAlpha = function() { 974 /// <returns type="number"/> 975 return this.alpha_; 976 }; 977 978 /** 979 * Sets the alpha value. 980 * @param {number} alpha 981 * @const 982 */ 983 createjs.DisplayObject.prototype.setAlpha = function(alpha) { 984 /// <param type="number" name="alpha"/> 985 alpha = createjs.getNumber(alpha); 986 if (this.alpha_ != alpha) { 987 this.alpha_ = alpha; 988 this.setDirty(!alpha ? createjs.DisplayObject.DIRTY_ALL : 989 createjs.DisplayObject.DIRTY_PROPERTIES); 990 } 991 }; 992 993 /** 994 * Retrieves the shadow properties. 995 * @return {createjs.Shadow} 996 * @const 997 */ 998 createjs.DisplayObject.prototype.getShadow = function() { 999 /// <returns type="createjs.Shadow"/> 1000 return this.shadow_; 1001 }; 1002 1003 /** 1004 * Sets the shadow properties. 1005 * @param {createjs.Shadow} shadow 1006 * @const 1007 */ 1008 createjs.DisplayObject.prototype.setShadow = function(shadow) { 1009 /// <param type="createjs.Shadow" name="shadow"/> 1010 if (this.shadow_) { 1011 if (this.shadow_.color == shadow.color || 1012 this.shadow_.offsetX == shadow.offsetX || 1013 this.shadow_.offsetY == shadow.offsetY || 1014 this.shadow_.blur == shadow.blur) { 1015 return; 1016 } 1017 } 1018 this.shadow_ = shadow; 1019 this.setDirty(createjs.DisplayObject.DIRTY_PROPERTIES); 1020 }; 1021 1022 /** 1023 * Retrieves the composite operation. 1024 * @return {string} 1025 * @const 1026 */ 1027 createjs.DisplayObject.prototype.getComposition = function() { 1028 /// <returns type="string"/> 1029 return createjs.Renderer.getCompositionName(this.composition_); 1030 }; 1031 1032 /** 1033 * Sets the composite operation. 1034 * @param {string} value 1035 * @const 1036 */ 1037 createjs.DisplayObject.prototype.setComposition = function(value) { 1038 /// <param type="string" name="value"/> 1039 var composition = createjs.Renderer.getCompositionKey(value); 1040 if (this.composition_ != composition) { 1041 this.composition_ = composition; 1042 this.setDirty(createjs.DisplayObject.DIRTY_PROPERTIES); 1043 } 1044 }; 1045 1046 /** 1047 * Retrieves the list of filters. 1048 * @return {Array.<createjs.Filter>} 1049 * @const 1050 */ 1051 createjs.DisplayObject.prototype.getFilters = function() { 1052 /// <returns type="Array" elementType="createjs.Filter"/> 1053 return []; 1054 }; 1055 1056 /** 1057 * Returns the alpha-map filter attached to this object. 1058 * @return {createjs.AlphaMapFilter} 1059 * @protected 1060 * @const 1061 */ 1062 createjs.DisplayObject.prototype.getAlphaMapFilter = function() { 1063 /// <returns type="createjs.AlphaMapFilter"/> 1064 return this.alphaMapFilter_; 1065 }; 1066 1067 /** 1068 * Returns the color filter attached to this object. 1069 * @return {Array.<number>} 1070 * @protected 1071 * @const 1072 */ 1073 createjs.DisplayObject.prototype.getColorMatrix = function() { 1074 /// <returns type="Array" elementType="number"/> 1075 return this.colorMatrix_; 1076 }; 1077 1078 /** 1079 * Sets the list of filters. 1080 * @param {Array.<createjs.Filter>} filters 1081 * @const 1082 */ 1083 createjs.DisplayObject.prototype.setFilters = function(filters) { 1084 /// <param type="Array" elementType="createjs.Filter" name="filters"/> 1085 // Extract an alpha-map filter, a color filter, and a color-matrix filter from 1086 // the input list. (A color filter is converted to a color matrix so our 1087 // fragment shader can apply it to images.) 1088 var alphaFilter = null; 1089 var colorMatrix = null; 1090 for (var i = filters.length - 1; i >= 0; --i) { 1091 var filter = filters[i]; 1092 var type = filter.getType(); 1093 if (type == createjs.Filter.Type.COLOR) { 1094 var colorFilter = createjs.ColorFilter.get(filter); 1095 var multiplier = colorFilter.multiplier; 1096 var offset = colorFilter.offset; 1097 colorMatrix = [ 1098 multiplier.getRed(), 0, 0, 0, offset.getRed(), 1099 0, multiplier.getGreen(), 0, 0, offset.getGreen(), 1100 0, 0, multiplier.getBlue(), 0, offset.getBlue(), 1101 0, 0, 0, 1, 0, 1102 0, 0, 0, 0, 1 1103 ]; 1104 } else if (type == createjs.Filter.Type.ALPHA_MAP) { 1105 alphaFilter = createjs.AlphaMapFilter.get(filter); 1106 } else if (type == createjs.Filter.Type.COLOR_MATRIX) { 1107 var colorMatrixFilter = createjs.ColorMatrixFilter.get(filter); 1108 colorMatrix = colorMatrixFilter.getMatrix(); 1109 } 1110 } 1111 if (this.alphaMapFilter_ === alphaFilter && 1112 this.colorMatrix_ === colorMatrix) { 1113 return; 1114 } 1115 this.alphaMapFilter_ = alphaFilter; 1116 this.colorMatrix_ = colorMatrix; 1117 this.setDirty(createjs.DisplayObject.DIRTY_SHAPE); 1118 1119 // Apply an alpha-map filter to this object and cache the filtered image to a 1120 // memory <canvas> element. 1121 this.handleDetach(); 1122 this.handleAttach(1); 1123 }; 1124 1125 /** 1126 * Retrieves the masking path. 1127 * @return {createjs.DisplayObject} 1128 * @const 1129 */ 1130 createjs.DisplayObject.prototype.getMask = function() { 1131 /// <returns type="createjs.DisplayObject"/> 1132 return this.mask_; 1133 }; 1134 1135 /** 1136 * Sets the masking path. 1137 * @param {createjs.DisplayObject} mask 1138 * @const 1139 */ 1140 createjs.DisplayObject.prototype.setMask = function(mask) { 1141 /// <param name="mask" type="createjs.DisplayObject"/> 1142 // Over-write the '_off' property of this mask so the 'layout()' method can 1143 // calculate its bounding box. (It does not have to be drawable, though.) 1144 mask['_off'] = false; 1145 1146 // Add this object to an owner of this mask so the mask can set its dirty 1147 // flag when it has its createjs.Graphics object changed by a tween. 1148 if (!mask.owners_) { 1149 mask.owners_ = []; 1150 } 1151 for (var i = 0; i < mask.owners_.length; ++i) { 1152 if (mask.owners_[i] === this) { 1153 return; 1154 } 1155 } 1156 mask.owners_.push(this); 1157 1158 // Set the composition command to draw this object over the mask. 1159 mask.composition_ = createjs.Renderer.Mask.COMPOSE; 1160 mask.state_.composition_ = createjs.Renderer.Composition.DESTINATION_IN; 1161 this.composition_ = createjs.Renderer.Composition.SOURCE_OVER; 1162 1163 // Draw the mask onto a memory <canvas> element. 1164 var type = 2; 1165 mask.handleAttach(type); 1166 this.mask_ = mask; 1167 this.clip_ = null; 1168 this.setDirty(createjs.DisplayObject.DIRTY_MASK); 1169 }; 1170 1171 /** 1172 * Returns the display object which owns this object only if this object is a 1173 * mask. 1174 * @return {Array.<createjs.DisplayObject>} 1175 * @protected 1176 * @const 1177 */ 1178 createjs.DisplayObject.prototype.getOwners = function() { 1179 /// <returns type="Array" elementType="createjs.DisplayObject"/> 1180 return this.owners_; 1181 }; 1182 1183 /** 1184 * Retrieves the ID of the composite operation. 1185 * @return {number} 1186 * @protected 1187 * @const 1188 */ 1189 createjs.DisplayObject.prototype.getCompositionId = function() { 1190 /// <returns type="number"/> 1191 return this.composition_; 1192 }; 1193 1194 /** 1195 * Retrieves the parent of this object. 1196 * @return {createjs.DisplayObject} 1197 * @protected 1198 */ 1199 createjs.DisplayObject.prototype.getParent = function() { 1200 /// <returns type="createjs.DisplayObject"/> 1201 return /** @type {createjs.DisplayObject} */ (this['parent']); 1202 }; 1203 1204 /** 1205 * Returns a set of parameters used for rendering this object. 1206 * @return {createjs.DisplayObject.RenderState} 1207 * @protected 1208 */ 1209 createjs.DisplayObject.prototype.getState = function() { 1210 /// <returns type="createjs.DisplayObject.RenderState"/> 1211 return this.state_; 1212 }; 1213 1214 /** 1215 * Returns the inverse-affine transformation used for transforming a point in 1216 * the global coordination to a point in the coordination of this object. 1217 * @return {createjs.Transform} 1218 * @protected 1219 */ 1220 createjs.DisplayObject.prototype.getInverse = function() { 1221 /// <returns type="createjs.Transform"/> 1222 if (!this.inverse_) { 1223 this.inverse_ = this.state_.getInverse(); 1224 } 1225 return this.inverse_; 1226 }; 1227 1228 /** 1229 * Sets the horizontal position. 1230 * @param {createjs.DisplayObject} parent 1231 * @protected 1232 */ 1233 createjs.DisplayObject.prototype.setParent = function(parent) { 1234 createjs.assert(parent != this); 1235 this['parent'] = parent; 1236 }; 1237 1238 /** 1239 * Returns the bounding box of this object. 1240 * @return {createjs.BoundingBox} 1241 * @protected 1242 */ 1243 createjs.DisplayObject.prototype.getBoundingBox = function() { 1244 /// <returns type="createjs.BoundingBox"/> 1245 return this.box_; 1246 }; 1247 1248 /** 1249 * Sets the bounding box of this object. 1250 * @param {number} minX 1251 * @param {number} minY 1252 * @param {number} maxX 1253 * @param {number} maxY 1254 * @protected 1255 */ 1256 createjs.DisplayObject.prototype.setBoundingBox = 1257 function(minX, minY, maxX, maxY) { 1258 if (this.box_.minX != minX || this.box_.minY != minY || 1259 this.box_.maxX != maxX || this.box_.maxY != maxY) { 1260 this.box_.minX = minX; 1261 this.box_.minY = minY; 1262 this.box_.maxX = maxX; 1263 this.box_.maxY = maxY; 1264 this.setDirty(createjs.DisplayObject.DIRTY_BOX); 1265 } 1266 }; 1267 1268 /** 1269 * Retrieves the width of this object. 1270 * @return {number} 1271 * @protected 1272 */ 1273 createjs.DisplayObject.prototype.getBoxWidth = function() { 1274 /// <returns type="number"/> 1275 return this.box_.getWidth(); 1276 }; 1277 1278 /** 1279 * Retrieves the height of this object. 1280 * @return {number} 1281 * @protected 1282 */ 1283 createjs.DisplayObject.prototype.getBoxHeight = function() { 1284 /// <returns type="number"/> 1285 return this.box_.getHeight(); 1286 }; 1287 1288 /** 1289 * Returns the current position of the tweens attached to this object. 1290 * @return {number} 1291 * @protected 1292 */ 1293 createjs.DisplayObject.prototype.getCurrentFrame = function() { 1294 /// <returns type="number"/> 1295 return this.currentFrame_; 1296 }; 1297 1298 /** 1299 * Sets the current position of the tweens attached to this object. 1300 * @param {number} frame 1301 * @protected 1302 */ 1303 createjs.DisplayObject.prototype.setCurrentFrame = function(frame) { 1304 /// <param type="number" name="frame"/> 1305 this.currentFrame_ = frame; 1306 }; 1307 1308 /** 1309 * Returns whether this object is playing its tweens or its sprite sheet. 1310 * @return {boolean} 1311 * @protected 1312 */ 1313 createjs.DisplayObject.prototype.isPaused = function() { 1314 /// <returns type="boolean"/> 1315 return this.paused_; 1316 }; 1317 1318 /** 1319 * Sets the current playing status of its tweens or its sprite sheet. 1320 * @param {boolean} paused 1321 * @protected 1322 */ 1323 createjs.DisplayObject.prototype.setIsPaused = function(paused) { 1324 /// <param type="boolean" name="paused"/> 1325 this.paused_ = paused; 1326 }; 1327 1328 /** 1329 * Destroys all properties of this object. 1330 * @protected 1331 * @const 1332 */ 1333 createjs.DisplayObject.prototype.destroy = function() { 1334 for (var key in this) { 1335 var value = this[key]; 1336 if (value && createjs.isObject(value)) { 1337 this[key] = null; 1338 } 1339 } 1340 this.visible_ = false; 1341 }; 1342 1343 /** 1344 * Adds a child (or children) to the top of this display object. 1345 * @param {...createjs.DisplayObject} var_args 1346 * @return {createjs.DisplayObject} 1347 */ 1348 createjs.DisplayObject.prototype.addChild = function(var_args) { 1349 /// <param type="createjs.DisplayObject" name="var_args"/> 1350 /// <returns type="createjs.DisplayObject"/> 1351 createjs.notReached(); 1352 return null; 1353 }; 1354 1355 /** 1356 * Adds a child (or children) to this display object at the specified index. 1357 * @param {...(createjs.DisplayObject|number)} var_args 1358 * @return {createjs.DisplayObject} 1359 */ 1360 createjs.DisplayObject.prototype.addChildAt = function(var_args) { 1361 /// <param type="createjs.DisplayObject" name="var_args"/> 1362 /// <returns type="createjs.DisplayObject"/> 1363 createjs.notReached(); 1364 return null; 1365 }; 1366 1367 /** 1368 * Removes the specified child (or children) from this display object. 1369 * @param {...createjs.DisplayObject} var_args 1370 * @return {boolean} 1371 */ 1372 createjs.DisplayObject.prototype.removeChild = function(var_args) { 1373 /// <param type="createjs.DisplayObject" name="var_args"/> 1374 /// <returns type="boolean"/> 1375 createjs.notReached(); 1376 return false; 1377 }; 1378 1379 /** 1380 * Removes the child (or children) at the specified index from this display 1381 * object. 1382 * @param {...number} var_args 1383 * @return {boolean} 1384 */ 1385 createjs.DisplayObject.prototype.removeChildAt = function(var_args) { 1386 /// <returns type="boolean"/> 1387 createjs.notReached(); 1388 return false; 1389 }; 1390 1391 /** 1392 * Removes all children from this display object. 1393 * @param {boolean=} opt_destroy 1394 */ 1395 createjs.DisplayObject.prototype.removeAllChildren = function(opt_destroy) { 1396 /// <param type="boolean" optional="true" name="opt_destroy"/> 1397 }; 1398 1399 /** 1400 * Called when this display object is attached to another display object as its 1401 * child. 1402 * @param {number} flag 1403 * @protected 1404 */ 1405 createjs.DisplayObject.prototype.handleAttach = function(flag) { 1406 /// <param type="number" name="flag"/> 1407 }; 1408 1409 /** 1410 * Called when this display object is detached from another display object. 1411 * @protected 1412 */ 1413 createjs.DisplayObject.prototype.handleDetach = function() { 1414 }; 1415 1416 /** 1417 * Returns an object under the specified point. (This point is one in the global 1418 * coordinate.) 1419 * @param {createjs.Point} point 1420 * @param {number} types 1421 * @param {number} bubble 1422 * @return {createjs.DisplayObject} 1423 * @protected 1424 */ 1425 createjs.DisplayObject.prototype.hitTestObject = 1426 function(point, types, bubble) { 1427 /// <param type="createjs.Point" name="point"/> 1428 /// <param type="number" name="types"/> 1429 /// <param type="number" name="bubble"/> 1430 /// <returns type="createjs.DisplayObject"/> 1431 bubble |= types & this.getEventTypes(); 1432 if (!bubble) { 1433 return null; 1434 } 1435 // Return null when the given point is not in the (global) bounding box of 1436 // this object to avoid testing the point with DisplayObject objects that 1437 // do not obviously contain it. 1438 var state = this.getState(); 1439 var clip = state.getClip(); 1440 var box = clip ? clip.getBox() : state.box_; 1441 if (!this.isVisible() || !box.contain(point.x, point.y)) { 1442 return null; 1443 } 1444 // The above bounding box becomes equal to the frame rectangle of this object 1445 // only when this object is not either rotated or skewed. When this object is 1446 // either rotated or skewed, this function needs to translate the point into 1447 // the local coordinate of this object and tests whether the translated point 1448 // is in the frame rectangle. 1449 var transform = clip ? clip.getTransform() : state; 1450 if (transform.b || transform.c) { 1451 var region = clip ? clip.getRectangle() : this.getBoundingBox(); 1452 if (!transform.invertible || region.isEmpty()) { 1453 return null; 1454 } 1455 var local = new createjs.Point(point.x, point.y); 1456 transform.getInverse().transformPoint(local); 1457 if (!region.contain(local.x, local.y)) { 1458 return null; 1459 } 1460 } 1461 return this; 1462 }; 1463 1464 /** 1465 * Returns all objects under the specified point. 1466 * @param {createjs.Point} point 1467 * @param {Array.<createjs.DisplayObject>} list 1468 * @param {number} types 1469 * @param {number} bubble 1470 * @protected 1471 */ 1472 createjs.DisplayObject.prototype.hitTestObjects = 1473 function(point, list, types, bubble) { 1474 /// <param type="createjs.Point" name="point"/> 1475 /// <param type="Array" elementType="createjs.DisplayObject" name="list"/> 1476 /// <param type="number" name="types"/> 1477 /// <param type="number" name="bubble"/> 1478 var result = this.hitTestObject(point, types, bubble); 1479 if (result) { 1480 list.push(result); 1481 } 1482 }; 1483 1484 /** 1485 * Updates the rendering state of this object. 1486 * @param {createjs.DisplayObject} parent 1487 * @param {number} dirty 1488 * @protected 1489 */ 1490 createjs.DisplayObject.prototype.updateLayout = function(parent, dirty) { 1491 /// <param type="createjs.DisplayObject" name="parent"/> 1492 /// <param type="number" name="dirty"/> 1493 // Append transform of this object and its properties to the current rendering 1494 // state to create a composite rendering state. 1495 if (createjs.DEBUG) { 1496 ++createjs.Counter.totalObjects; 1497 } 1498 var state = this.state_; 1499 if (dirty & createjs.DisplayObject.DIRTY_TRANSFORM) { 1500 state.appendTransform(parent.state_, 1501 this.position_, 1502 this.scale_, 1503 this.rotation_, 1504 this.skew_, 1505 this.registration_); 1506 this.inverse_ = null; 1507 } 1508 if (dirty & createjs.DisplayObject.DIRTY_PROPERTIES) { 1509 state.appendProperties(parent.state_, 1510 this.alpha_, 1511 this.shadow_, 1512 this.composition_, 1513 this.visible_); 1514 } 1515 if (dirty & createjs.DisplayObject.DIRTY_MASK) { 1516 if (this.mask_ && !this.mask_.box_.isEmpty()) { 1517 this.updateClip_(parent); 1518 } 1519 state.appendClip(parent.state_, this.clip_); 1520 } 1521 }; 1522 1523 /** 1524 * Updates the layout of this object. 1525 * @param {createjs.Renderer} renderer 1526 * @param {createjs.DisplayObject} parent 1527 * @param {number} dirty 1528 * @param {number} time 1529 * @param {number} draw 1530 * @return {number} 1531 * @protected 1532 */ 1533 createjs.DisplayObject.prototype.layout = 1534 function(renderer, parent, dirty, time, draw) { 1535 /// <param type="createjs.Renderer" name="renderer"/> 1536 /// <param type="createjs.DisplayObject" name="parent"/> 1537 /// <param type="number" name="dirty"/> 1538 /// <param type="number" name="time"/> 1539 /// <param type="number" name="draw"/> 1540 /// <returns type="number"/> 1541 var state = this.state_; 1542 if (!this.isVisible()) { 1543 // Prohibit dispatching events to this object when it is invisible. 1544 return 0; 1545 } 1546 dirty |= this.dirty; 1547 if (dirty) { 1548 this.updateLayout(parent, dirty); 1549 var DIRTY_BOX = createjs.DisplayObject.DIRTY_TRANSFORM | 1550 createjs.DisplayObject.DIRTY_BOX; 1551 if (!state.getClip() && (dirty & DIRTY_BOX)) { 1552 state.updateBox(this.box_); 1553 } 1554 } 1555 // Render this object if the renderer can render it. (The WebGL renderer 1556 // cannot render this object as expected when its affine transformation is not 1557 // invertible, i.e. its affine-transformed shape is not a rectangle.) 1558 draw &= state.invertible; 1559 if (draw) { 1560 renderer.addObject(this); 1561 } 1562 parent.state_.inflateBox(state); 1563 return this.getEventTypes(); 1564 }; 1565 1566 /** @override */ 1567 createjs.DisplayObject.prototype.isDirtyObject = function(box) { 1568 /// <param type="createjs.BoundingBox" name="box"/> 1569 /// <returns type="boolean"/> 1570 if (!this.dirty && !box.hasIntersection(this.state_.getBox())) { 1571 return false; 1572 } 1573 return true; 1574 }; 1575 1576 /** @override */ 1577 createjs.DisplayObject.prototype.getRenderBox = function() { 1578 /// <returns type="createjs.BoundingBox"/> 1579 return this.state_.getBox(); 1580 }; 1581 1582 /** @override */ 1583 createjs.DisplayObject.prototype.getClip = function() { 1584 /// <returns type="createjs.Renderer.Clip"/> 1585 return this.state_.getClip(); 1586 }; 1587 1588 /** @override */ 1589 createjs.DisplayObject.prototype.beginPaintObject = function(renderer) { 1590 /// <param type="createjs.Renderer" name="renderer"/> 1591 this.dirty = 0; 1592 var state = this.state_; 1593 createjs.assert(!!state.invertible); 1594 renderer.setTransformation( 1595 state.a, state.b, state.c, state.d, state.tx, state.ty); 1596 renderer.setAlpha(state.alpha_); 1597 renderer.setComposition(state.composition_); 1598 }; 1599 1600 /** @override */ 1601 createjs.DisplayObject.prototype.paintObject = function(renderer) { 1602 /// <returns type="createjs.Renderer"/> 1603 }; 1604 1605 /** 1606 * Returns whether this display object is visible. 1607 * @return {boolean} 1608 */ 1609 createjs.DisplayObject.prototype.isVisible = function() { 1610 /// <returns type="boolean"/> 1611 return this.visible_ && !!this.alpha_ && !!this.scale_.x && !!this.scale_.y; 1612 }; 1613 1614 /** 1615 * Draws this display object into the specified <canvas> context. (This method 1616 * is deprecated because it does not work with WebGL.) 1617 * @param {CanvasRenderingContext2D} context 1618 * @param {boolean} ignoreCache 1619 * @return {boolean} 1620 * @deprecated 1621 */ 1622 createjs.DisplayObject.prototype.draw = function(context, ignoreCache) { 1623 /// <param type="CanvasRenderingContext2D" name="context"/> 1624 /// <param type="boolean" name="ignoreCache"/> 1625 return false; 1626 }; 1627 1628 /** 1629 * Applies this display object's transformation, alpha, composite operation, 1630 * clipping path (mask), and shadow to the specified context. (This method is 1631 * deprecated because it does not work with WebGL.) 1632 * @param {CanvasRenderingContext2D} context 1633 * @deprecated 1634 */ 1635 createjs.DisplayObject.prototype.updateContext = function(context) { 1636 /// <param type="CanvasRenderingContext2D" name="context"/> 1637 }; 1638 1639 /** 1640 * Draws this display object into a cache <canvas> element. (This method is 1641 * deprecated because derived objects have caches optimized for them.) 1642 * @param {number} x 1643 * @param {number} y 1644 * @param {number} width 1645 * @param {number} height 1646 * @param {number=} opt_scale 1647 * @deprecated 1648 */ 1649 createjs.DisplayObject.prototype.cache = 1650 function(x, y, width, height, opt_scale) { 1651 /// <param type="number" name="x"/> 1652 /// <param type="number" name="y"/> 1653 /// <param type="number" name="width"/> 1654 /// <param type="number" name="height"/> 1655 /// <param type="number" optional="true" name="opt_scale"/> 1656 }; 1657 1658 /** 1659 * Redraws this display object to a cache <canvas> element. 1660 * @param {string} compositeOperation 1661 * @deprecated 1662 */ 1663 createjs.DisplayObject.prototype.updateCache = function(compositeOperation) { 1664 /// <param type="string" name="compositeOperation"/> 1665 }; 1666 1667 /** 1668 * Clears the cache <canvas> element. 1669 * @deprecated 1670 */ 1671 createjs.DisplayObject.prototype.uncache = function() { 1672 }; 1673 1674 /** 1675 * Returns a data URL of the cache <canvas> element. 1676 * @return {string} 1677 * @deprecated 1678 */ 1679 createjs.DisplayObject.prototype.getCacheDataURL = function() { 1680 /// <returns type="string"/> 1681 return ''; 1682 }; 1683 1684 /** 1685 * Returns the createjs.Stage object to which that this display object belongs 1686 * to, or null if it is detached. 1687 * @return {createjs.DisplayObject} 1688 */ 1689 createjs.DisplayObject.prototype.getStage = function() { 1690 /// <returns type="createjs.DisplayObject"/> 1691 var o = this; 1692 while (o.getParent()) { 1693 o = o.getParent(); 1694 } 1695 return o.isStage ? o : null; 1696 }; 1697 1698 /** 1699 * Transforms the specified x and y position from the coordinate of this object 1700 * to the global coordinate. 1701 * @param {number} x 1702 * @param {number} y 1703 * @return {createjs.Point} 1704 */ 1705 createjs.DisplayObject.prototype.localToGlobal = function(x, y) { 1706 /// <param type="number" name="x"/> 1707 /// <param type="number" name="y"/> 1708 /// <returns type="createjs.Point"/> 1709 var point = new createjs.Point(x, y); 1710 return this.state_.transformPoint(point); 1711 }; 1712 1713 /** 1714 * Transforms the specified x and y position from the global coordinate to the 1715 * one of this object. 1716 * @param {number} x 1717 * @param {number} y 1718 * @return {createjs.Point} 1719 */ 1720 createjs.DisplayObject.prototype.globalToLocal = function(x, y) { 1721 /// <param type="number" name="x"/> 1722 /// <param type="number" name="y"/> 1723 /// <returns type="createjs.Point"/> 1724 var point = new createjs.Point(x, y); 1725 return this.getInverse().transformPoint(point); 1726 }; 1727 1728 /** 1729 * Transforms the specified x and y position from the coordinate of this object 1730 * to the one of the specified target object. 1731 * @param {number} x 1732 * @param {number} y 1733 * @param {createjs.DisplayObject} target 1734 * @return {createjs.Point} 1735 */ 1736 createjs.DisplayObject.prototype.localToLocal = function(x, y, target) { 1737 /// <param type="number" name="x"/> 1738 /// <param type="number" name="y"/> 1739 /// <param type="createjs.DisplayObject" name="target"/> 1740 /// <returns type="createjs.Point"/> 1741 var point = this.localToGlobal(x, y); 1742 return target.getInverse().transformPoint(point); 1743 }; 1744 1745 /** 1746 * Sets the transform properties on this display object. 1747 * @param {number} x 1748 * @param {number} y 1749 * @param {number} scaleX 1750 * @param {number} scaleY 1751 * @param {number} rotation 1752 * @param {number} skewX 1753 * @param {number} skewY 1754 * @param {number} regX 1755 * @param {number} regY 1756 * @return {createjs.DisplayObject} 1757 */ 1758 createjs.DisplayObject.prototype.setTransform = 1759 function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) { 1760 /// <param type="number" optional="true" name="x"/> 1761 /// <param type="number" optional="true" name="y"/> 1762 /// <param type="number" optional="true" name="scaleX"/> 1763 /// <param type="number" optional="true" name="scaleY"/> 1764 /// <param type="number" optional="true" name="rotation"/> 1765 /// <param type="number" optional="true" name="skewX"/> 1766 /// <param type="number" optional="true" name="skewY"/> 1767 /// <param type="number" optional="true" name="regX"/> 1768 /// <param type="number" optional="true" name="regY"/> 1769 /// <returns type="createjs.DisplayObject"/> 1770 this.setX(x || 0); 1771 this.setY(y || 0); 1772 this.setScaleX(scaleX == null ? 1 : scaleX); 1773 this.setScaleY(scaleY == null ? 1 : scaleY); 1774 this.setSkewX(skewX || 0); 1775 this.setSkewY(skewY || 0); 1776 this.setRegX(regX || 0); 1777 this.setRegY(regY || 0); 1778 this.setRotation(rotation || 0); 1779 return this; 1780 }; 1781 1782 /** 1783 * Tests whether this display object intersects the specified local point. 1784 * @param {number} x 1785 * @param {number} y 1786 * @return {boolean} 1787 */ 1788 createjs.DisplayObject.prototype.hitTest = function(x, y) { 1789 /// <param type="number" name="x"/> 1790 /// <param type="number" name="y"/> 1791 /// <returns type="boolean"/> 1792 return !!this.hitTestObject(new createjs.Point(x, y), 0, 1); 1793 }; 1794 1795 /** 1796 * Sets properties of this DisplayObject object. 1797 * @param {Object} properties 1798 * @return {createjs.DisplayObject} 1799 */ 1800 createjs.DisplayObject.prototype.set = function(properties) { 1801 /// <param type="Object" name="properties"/> 1802 /// <returns type="createjs.DisplayObject"/> 1803 var KEYS = { 1804 'x': createjs.DisplayObject.prototype.setX, 1805 'y': createjs.DisplayObject.prototype.setY, 1806 'scaleX': createjs.DisplayObject.prototype.setScaleX, 1807 'scaleY': createjs.DisplayObject.prototype.setScaleY, 1808 'skewX': createjs.DisplayObject.prototype.setSkewX, 1809 'skewY': createjs.DisplayObject.prototype.setSkewY, 1810 'regX': createjs.DisplayObject.prototype.setRegX, 1811 'regY': createjs.DisplayObject.prototype.setRegY, 1812 'rotation': createjs.DisplayObject.prototype.setRotation, 1813 'visible': createjs.DisplayObject.prototype.setVisible, 1814 'alpha': createjs.DisplayObject.prototype.setAlpha, 1815 '_off': createjs.DisplayObject.prototype.setOff, 1816 'compositeOperation': createjs.DisplayObject.prototype.setComposition 1817 }; 1818 for (var key in properties) { 1819 var setter = KEYS[key]; 1820 if (setter) { 1821 var value = properties[key]; 1822 setter.call(this, value); 1823 } 1824 } 1825 return this; 1826 }; 1827 1828 /** 1829 * Returns a rectangle representing this object's bounds in its local coordinate 1830 * system, i.e. without affine transformation. This method converts the bounding 1831 * box calculated in rendering this object to a createjs.Rectangle object and 1832 * returns it. (This method returns an empty rectangle when it has never been 1833 * rendered.) 1834 * @return {createjs.Rectangle} 1835 */ 1836 createjs.DisplayObject.prototype.getBounds = function() { 1837 /// <returns type="createjs.Rectangle"/> 1838 var x = this.box_.getLeft(); 1839 var y = this.box_.getTop(); 1840 var width = this.box_.getWidth(); 1841 var height = this.box_.getHeight(); 1842 if (!this.rectangle_) { 1843 this.rectangle_ = new createjs.Rectangle(x, y, width, height); 1844 } else { 1845 this.rectangle_.initialize(x, y, width, height); 1846 } 1847 return this.rectangle_; 1848 }; 1849 1850 /** 1851 * Returns a rectangle representing this object's bounds in the coordinate 1852 * system of its parent. 1853 * @return {createjs.Rectangle} 1854 */ 1855 createjs.DisplayObject.prototype.getTransformedBounds = function() { 1856 /// <returns type="createjs.Rectangle"/> 1857 createjs.notImplemented(); 1858 return this.rectangle_; 1859 }; 1860 1861 /** 1862 * Allows you to manually specify the bounds of an object. (This method is 1863 * deprecated because each display object calculates its bounds correctly.) 1864 * @param {number} x 1865 * @param {number} y 1866 * @param {number} width 1867 * @param {number} height 1868 * @deprecated 1869 */ 1870 createjs.DisplayObject.prototype.setBounds = function(x, y, width, height) { 1871 /// <param type="number" name="x"/> 1872 /// <param type="number" name="y"/> 1873 /// <param type="number" name="width"/> 1874 /// <param type="number" name="height"/> 1875 }; 1876 1877 /** @override */ 1878 createjs.DisplayObject.prototype.registerTween = function(tween) { 1879 if (!this.tweens_) { 1880 this.tweens_ = new createjs.DisplayObject.ObjectList(); 1881 } else { 1882 if (this.tweens_.findItem(tween) >= 0) { 1883 return; 1884 } 1885 } 1886 this.tweens_.unshiftItem(tween); 1887 1888 // Start playing the tweens attached to this object without changing the 1889 // status of the other tweens, i.e. registering a tween should not play the 1890 // paused tweens attached to this object. 1891 this.paused_ = false; 1892 }; 1893 1894 /** @override */ 1895 createjs.DisplayObject.prototype.unregisterTween = function(tween) { 1896 if (this.tweens_) { 1897 this.tweens_.removeItem(tween); 1898 } 1899 }; 1900 1901 /** @override */ 1902 createjs.DisplayObject.prototype.resetTweens = function() { 1903 if (this.tweens_) { 1904 this.tweens_.stopTweens_(0); 1905 this.tweens_ = null; 1906 } 1907 this.synchronized_ = null; 1908 }; 1909 1910 /** @override */ 1911 createjs.DisplayObject.prototype.playTweens = function(time) { 1912 /// <param type="number" name="time"/> 1913 if (this.paused_ || this.synchronized_) { 1914 this.paused_ = false; 1915 if (this.synchronized_) { 1916 for (var i = 0; i < this.synchronized_.length; ++i) { 1917 var target = this.synchronized_[i]; 1918 target.playTweens(time); 1919 } 1920 } 1921 } 1922 }; 1923 1924 /** @override */ 1925 createjs.DisplayObject.prototype.stopTweens = function(time) { 1926 /// <param type="number" name="time"/> 1927 // Immediately stop all tweens attached to this display object and being 1928 // synchronized with it. (This method is usually called by an action tween 1929 // while a display object is executes the updateTween() method.) 1930 if (!this.paused_) { 1931 this.paused_ = true; 1932 if (this.synchronized_) { 1933 for (var i = 0; i < this.synchronized_.length; ++i) { 1934 this.synchronized_[i].stopTweens(time); 1935 } 1936 } 1937 } 1938 }; 1939 1940 /** @override */ 1941 createjs.DisplayObject.prototype.updateTweens = function(time) { 1942 /// <param type="number" name="time"/> 1943 if (this.hasTweens()) { 1944 if (!this.paused_ || this.seek_) { 1945 this.seek_ = false; 1946 this.currentFrame_ = this.tweens_.updateTweens_(time, this.getPlayMode()); 1947 } 1948 } 1949 }; 1950 1951 /** @override */ 1952 createjs.DisplayObject.prototype.hasTweens = function() { 1953 return !!this.tweens_ && !!this.tweens_.getLength(); 1954 }; 1955 1956 /** @override */ 1957 createjs.DisplayObject.prototype.setTweenPosition = function(position) { 1958 if (this.tweens_) { 1959 this.tweens_.setPositions_( 1960 createjs.Ticker.getRunTime(), position, this.paused_); 1961 } 1962 if (this.synchronized_) { 1963 for (var i = 0; i < this.synchronized_.length; ++i) { 1964 this.synchronized_[i].setTweenPosition(position); 1965 } 1966 } 1967 this.seek_ = true; 1968 }; 1969 1970 /** @override */ 1971 createjs.DisplayObject.prototype.setTweenProperties = 1972 function(loop, position, single) { 1973 if (this.tweens_) { 1974 this.tweens_.setProperties_(this, loop, position, single); 1975 } 1976 }; 1977 1978 /** @override */ 1979 createjs.DisplayObject.prototype.getOff = function() { 1980 /// <returns type="boolean"/> 1981 return this['_off']; 1982 }; 1983 1984 /** @override */ 1985 createjs.DisplayObject.prototype.setOff = function(off) { 1986 /// <param type="boolean" name="off"/> 1987 if (this.getOff() != off) { 1988 this['_off'] = off; 1989 this.setDirty(createjs.DisplayObject.DIRTY_ALL); 1990 if (off) { 1991 this.setTweenPosition(0); 1992 } 1993 } 1994 }; 1995 1996 /** @override */ 1997 createjs.DisplayObject.prototype.getPlayMode = function() { 1998 /// <returns type="number"/> 1999 return this.playMode_; 2000 }; 2001 2002 /** @override */ 2003 createjs.DisplayObject.prototype.setPlayMode = function(mode) { 2004 /// <param type="number" name="mode"/> 2005 this.playMode_ = mode; 2006 }; 2007 2008 /** @override */ 2009 createjs.DisplayObject.prototype.synchronize = function(target, synchronize) { 2010 /// <param type="createjs.TweenTarget" name="target"/> 2011 /// <param type="boolean" name="synchronize"/> 2012 if (!this.synchronized_) { 2013 if (!synchronize) { 2014 return; 2015 } 2016 this.synchronized_ = []; 2017 } else { 2018 for (var i = 0; i < this.synchronized_.length; ++i) { 2019 if (this.synchronized_[i] === target) { 2020 if (!synchronize) { 2021 this.synchronized_.splice(i, 1); 2022 } 2023 return; 2024 } 2025 } 2026 } 2027 this.synchronized_.push(target); 2028 }; 2029 2030 /** @override */ 2031 createjs.DisplayObject.prototype.addGraphics = function(graphics) { 2032 /// <param type="createjs.Graphics" name="graphics"/> 2033 }; 2034 2035 /** @override */ 2036 createjs.DisplayObject.prototype.getSetters = function() { 2037 /// <returns type="Object" elementType="createjs.TweenTarget.Setter"/> 2038 if (!this.position_) { 2039 return null; 2040 } 2041 var setters = createjs.TweenTarget.Property.getSetters(); 2042 setters['_off'].setBoolean(this.getOff()); 2043 setters['x'].setNumber(this.position_.x); 2044 setters['y'].setNumber(this.position_.y); 2045 setters['scaleX'].setNumber(this.scale_.x); 2046 setters['scaleY'].setNumber(this.scale_.y); 2047 setters['skewX'].setNumber(this.skew_.x); 2048 setters['skewY'].setNumber(this.skew_.y); 2049 setters['regX'].setNumber(this.registration_.x); 2050 setters['regY'].setNumber(this.registration_.y); 2051 setters['rotation'].setNumber(this.rotation_); 2052 setters['visible'].setBoolean(this.visible_); 2053 setters['alpha'].setNumber(this.alpha_); 2054 2055 // Disable setters not available for this object. 2056 setters['startPosition'].setNull(); 2057 setters['loop'].setNull(); 2058 setters['mode'].setNull(); 2059 setters['text'].setNull(); 2060 setters['graphics'].setNull(); 2061 return setters; 2062 }; 2063 2064 // Add setters to allow tweens to change this object. 2065 createjs.TweenTarget.Property.addSetters({ 2066 '_off': createjs.DisplayObject.prototype.setOff, 2067 'x': createjs.DisplayObject.prototype.setX, 2068 'y': createjs.DisplayObject.prototype.setY, 2069 'scaleX': createjs.DisplayObject.prototype.setScaleX, 2070 'scaleY': createjs.DisplayObject.prototype.setScaleY, 2071 'skewX': createjs.DisplayObject.prototype.setSkewX, 2072 'skewY': createjs.DisplayObject.prototype.setSkewY, 2073 'regX': createjs.DisplayObject.prototype.setRegX, 2074 'regY': createjs.DisplayObject.prototype.setRegY, 2075 'rotation': createjs.DisplayObject.prototype.setRotation, 2076 'visible': createjs.DisplayObject.prototype.setVisible, 2077 'alpha': createjs.DisplayObject.prototype.setAlpha 2078 }); 2079 2080 // Add getters and setters for applications to access internal variables. 2081 Object.defineProperties(createjs.DisplayObject.prototype, { 2082 'x': { 2083 get: createjs.DisplayObject.prototype.getX, 2084 set: createjs.DisplayObject.prototype.setX 2085 }, 2086 'y': { 2087 get: createjs.DisplayObject.prototype.getY, 2088 set: createjs.DisplayObject.prototype.setY 2089 }, 2090 'scaleX': { 2091 get: createjs.DisplayObject.prototype.getScaleX, 2092 set: createjs.DisplayObject.prototype.setScaleX 2093 }, 2094 'scaleY': { 2095 get: createjs.DisplayObject.prototype.getScaleY, 2096 set: createjs.DisplayObject.prototype.setScaleY 2097 }, 2098 'skewX': { 2099 get: createjs.DisplayObject.prototype.getSkewX, 2100 set: createjs.DisplayObject.prototype.setSkewX 2101 }, 2102 'skewY': { 2103 get: createjs.DisplayObject.prototype.getSkewY, 2104 set: createjs.DisplayObject.prototype.setSkewY 2105 }, 2106 'regX': { 2107 get: createjs.DisplayObject.prototype.getRegX, 2108 set: createjs.DisplayObject.prototype.setRegX 2109 }, 2110 'regY': { 2111 get: createjs.DisplayObject.prototype.getRegY, 2112 set: createjs.DisplayObject.prototype.setRegY 2113 }, 2114 'rotation': { 2115 get: createjs.DisplayObject.prototype.getRotation, 2116 set: createjs.DisplayObject.prototype.setRotation 2117 }, 2118 'visible': { 2119 get: createjs.DisplayObject.prototype.getVisible, 2120 set: createjs.DisplayObject.prototype.setVisible 2121 }, 2122 'alpha': { 2123 get: createjs.DisplayObject.prototype.getAlpha, 2124 set: createjs.DisplayObject.prototype.setAlpha 2125 }, 2126 'shadow': { 2127 get: createjs.DisplayObject.prototype.getShadow, 2128 set: createjs.DisplayObject.prototype.setShadow 2129 }, 2130 'compositeOperation': { 2131 get: createjs.DisplayObject.prototype.getComposition, 2132 set: createjs.DisplayObject.prototype.setComposition 2133 }, 2134 'filters': { 2135 get: createjs.DisplayObject.prototype.getFilters, 2136 set: createjs.DisplayObject.prototype.setFilters 2137 }, 2138 'mask': { 2139 get: createjs.DisplayObject.prototype.getMask, 2140 set: createjs.DisplayObject.prototype.setMask 2141 }, 2142 'stage': { 2143 get: createjs.DisplayObject.prototype.getStage 2144 } 2145 }); 2146 2147 // Export the createjs.DisplayObject object to the global namespace. 2148 createjs.exportObject('createjs.DisplayObject', createjs.DisplayObject, { 2149 // createjs.DisplayObject methods 2150 'nominalBounds': createjs.DisplayObject.prototype.nominalBounds, 2151 'cache': createjs.notReached, 2152 'updateCache': createjs.notReached, 2153 'uncache': createjs.notReached, 2154 'getCacheDataURL': createjs.notReached, 2155 'getStage': createjs.DisplayObject.prototype.getStage, 2156 'localToGlobal': createjs.DisplayObject.prototype.localToGlobal, 2157 'globalToLocal': createjs.DisplayObject.prototype.globalToLocal, 2158 'localToLocal': createjs.DisplayObject.prototype.localToLocal, 2159 'setTransform': createjs.DisplayObject.prototype.setTransform, 2160 'hitTest': createjs.DisplayObject.prototype.hitTest, 2161 'set': createjs.DisplayObject.prototype.set, 2162 'getScaleX': createjs.DisplayObject.prototype.getScaleX, 2163 'setScaleX': createjs.DisplayObject.prototype.setScaleX, 2164 'getScaleY': createjs.DisplayObject.prototype.getScaleY, 2165 'setScaleY': createjs.DisplayObject.prototype.setScaleY, 2166 'getBounds': createjs.DisplayObject.prototype.getBounds, 2167 'setBounds': createjs.notReached 2168 // createjs.EventDispatcher methods 2169 // createjs.Object methods 2170 }); 2171