Log in

View Full Version : Killtimer (similar to clearInterval)



nate51
01-16-2009, 04:57 PM
I am using an AS that creates a simple timer for a slideshow (see code below)

MovieClip.prototype.timer = function(sec) {
//create time mc and loop
this.createEmptyMovieClip("time", 1);
this.time.t0 = getTimer();
this.time.t2 = sec*1000;
this.stop();
this.time.onEnterFrame = function() {
this.t1 = getTimer()-this.t0;
if (this.t1>this.t2) {
this._parent.play();
delete this.onEnterFrame;
}
};
};
MovieClip.prototype.killtimer = function() {
delete this.time.onEnterFrame;
};
This allows me to drop simple

timer(5);
in my frames for lets say a 5 second pause.

The second part of the code for killtimer works when on a frame, but when I try to apply it to a button it doesnt work.

Has anyone used anything similar to this or know how to make it work in a button?