diff --git a/src/extras/MovieClip.js b/src/extras/MovieClip.js index 43e32d2..0ca8760 100644 --- a/src/extras/MovieClip.js +++ b/src/extras/MovieClip.js @@ -56,13 +56,12 @@ this.onComplete = null; /** - * The MovieClips current frame index (this may not have to be a whole number) + * Elapsed time since animation has been started, used internally to display current texture * * @member {number} - * @default 0 - * @readonly + * @private */ - this.currentFrame = 0; + this._currentTime = 0; /** * Indicates if the MovieClip is currently playing @@ -111,7 +110,20 @@ { this._textures = value; - this.texture = this._textures[Math.floor(this.currentFrame) % this._textures.length]; + this.texture = this._textures[Math.floor(this._currentTime) % this._textures.length]; + } + }, + + /** + * The MovieClips current frame index + * + * @member {number} + * @readonly + */ + currentFrame: { + get: function () + { + return Math.floor(this._currentTime) % this._texture.length; } } @@ -156,9 +168,9 @@ { this.stop(); - this.currentFrame = frameNumber; + this._currentTime = frameNumber; - var round = Math.floor(this.currentFrame); + var round = Math.floor(this._currentTime); this._texture = this._textures[round % this._textures.length]; }; @@ -169,7 +181,7 @@ */ MovieClip.prototype.gotoAndPlay = function (frameNumber) { - this.currentFrame = frameNumber; + this._currentTime = frameNumber; this.play(); }; @@ -180,16 +192,16 @@ MovieClip.prototype.update = function (deltaTime) { - this.currentFrame += this.animationSpeed * deltaTime; + this._currentTime += this.animationSpeed * deltaTime; - var floor = Math.floor(this.currentFrame); + var floor = Math.floor(this._currentTime); if (floor < 0) { if (this.loop) { - this.currentFrame += this._textures.length; - this._texture = this._textures[this.currentFrame]; + this._currentTime += this._textures.length; + this._texture = this._textures[this._currentTime]; } else {