Return to Snippet

Revision: 2435
at February 16, 2007 02:59 by clapfouine


Initial Code
//will stop 'play', 'gotoAndPlay' and 'rewind', 'gotoAndRewind' functions
MovieClip.prototype.stopAll = function () {
        delete this.onEnterFrame;
        this.stop();
}

//will stop 'rewind', 'gotoAndRewind' functions
MovieClip.prototype.stopRewind = function () {
        delete this.onEnterFrame;
}

//will play the timeline backwards and continal to loop until 'stopAll', 'stopRewind' or 'pause' are called
//note: the 'rewind' function will cancel the 'play' function BUT the 'play' function will not cancel the 'rewind' function
//you must call 'stopAll' or 'stopRewind' before using 'play' when your timeline is playing backwards
MovieClip.prototype.rewind = function () {
        this.stop();
        this.onEnterFrame = function () {
                if (this._currentframe > 0) {
                        this.prevFrame ();
                } else {
                        this.gotoAndStop (this._totalframes);
                }
        }
}

//will goto the specified frame and play the timeline backwards and continal to loop until 'stopAll', 'stopRewind' or 'pause' are called
MovieClip.prototype.gotoAndRewind = function (frame) {
        this.gotoAndStop (frame);
        this.rewind();
}

//will pause the timeline for the specified amount of time. will always play forwards when the pause has finished
MovieClip.prototype.pause = function (time) {
        delete this.onEnterFrame;
        secondsToPause = time;
        pauseInt = setInterval (this, "restart", secondsToPause * 1000);
}

restart = function () {
        clearInterval (pauseInt);
        play();
}

Initial URL
http://www.flashgroup.net/forum/showthread.php?t=2323

Initial Description


Initial Title
Usefull timeline manipulation functions

Initial Tags
actionscript, flash

Initial Language
ActionScript