diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 722c34a..2211754 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -220,16 +220,27 @@ }, set: function (value) { + // reset previous mask if (this._mask) { this._mask.renderable = true; + this._mask.parent = null; } + // set mask to the passed in value this._mask = value; - if (this._mask) - { - this._mask.renderable = false; + // if a non-null value + if (value) { + // remove new mask from scene if it is in it + if (value.parent) { + value.parent.removeChild(value); + } + + // set this as the parent of the mask object + value.parent = this; + + value.renderable = false; } } }, @@ -321,6 +332,10 @@ wt.ty = tx * pt.b + ty * pt.d + pt.ty; } + if (this._mask) { + this._mask.updateTransform(); + } + // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha;