diff --git a/src/extras/MovieClip.js b/src/extras/MovieClip.js index b604386..c6395f4 100644 --- a/src/extras/MovieClip.js +++ b/src/extras/MovieClip.js @@ -56,13 +56,13 @@ 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 */ - this.currentFrame = 0; + this.totalTime = 0; /** * Indicates if the MovieClip is currently playing @@ -111,7 +111,20 @@ { this._textures = value; - this.texture = this._textures[Math.floor(this.currentFrame) % this._textures.length]; + this.texture = this._textures[Math.floor(this.totalTime) % this._textures.length]; + } + }, + + /** + * The MovieClips current frame index + * + * @member {number} + * @readonly + */ + currentFrame: { + get: function () + { + return Math.floor(this.totalTime) % this._texture.length; } } @@ -156,9 +169,9 @@ { this.stop(); - this.currentFrame = frameNumber; + this.totalTime = frameNumber; - var round = Math.floor(this.currentFrame); + var round = Math.floor(this.totalTime); this._texture = this._textures[round % this._textures.length]; }; @@ -169,7 +182,7 @@ */ MovieClip.prototype.gotoAndPlay = function (frameNumber) { - this.currentFrame = frameNumber; + this.totalTime = frameNumber; this.play(); }; @@ -180,16 +193,16 @@ MovieClip.prototype.update = function (deltaTime) { - this.currentFrame += this.animationSpeed * deltaTime; + this.totalTime += this.animationSpeed * deltaTime; - var floor = Math.floor(this.currentFrame); + var floor = Math.floor(this.totalTime); if (floor < 0) { if (this.loop) { - this.currentFrame += this._textures.length; - this._texture = this._textures[this.currentFrame]; + this.totalTime += this._textures.length; + this._texture = this._textures[this.totalTime]; } else {