diff --git a/src/extras/MovieClip.js b/src/extras/MovieClip.js index 1ac2bbe..5dc83e9 100644 --- a/src/extras/MovieClip.js +++ b/src/extras/MovieClip.js @@ -143,13 +143,7 @@ if (previousFrame !== this.currentFrame) { - this._texture = this._textures[this.currentFrame]; - this._textureID = -1; - - if (this.onFrameChange) - { - this.onFrameChange(this.currentFrame); - } + this.updateTexture(); } } @@ -160,8 +154,15 @@ */ gotoAndPlay(frameNumber) { + const previousFrame = this.currentFrame; + this._currentTime = frameNumber; + if (previousFrame !== this.currentFrame) + { + this.updateTexture(); + } + this.play(); } @@ -225,13 +226,23 @@ } else if (previousFrame !== this.currentFrame) { - this._texture = this._textures[this.currentFrame]; - this._textureID = -1; + this.updateTexture(); + } + } - if (this.onFrameChange) - { - this.onFrameChange(this.currentFrame); - } + /** + * Updates the displayed texture to match the current frame index + * + * @private + */ + updateTexture() + { + this._texture = this._textures[this.currentFrame]; + this._textureID = -1; + + if (this.onFrameChange) + { + this.onFrameChange(this.currentFrame); } }