Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clearInterval question

Status
Not open for further replies.

UKTim

Programmer
Feb 21, 2007
7
GB
Hi guys,
quick question about clearInterval() -
How come that after clearing an interval created with setInterval, the intervalID still persists?
If i trace intervalID after clearInterval has been called, it still returns the id :-/

In a class im writing , i'm executing some code depending on whether an interval has been cleared. Will i have to force intervalID = null each time i use clearInterval?

eg.
Code:
function callback() {
 trace("interval called: "+getTimer()+" ms.");
}

var intervalID:Number = setInterval(callback, 1000);

clearInt_btn.onRelease = function(){
 clearInterval( intervalID );
 trace("cleared interval: " + intervalID);
};
 
var intervalID:Number

Interval IDs are just number variables such as 1, 2, 3 etc. "clearInterval" stops function call but does nothing else such as deleting variables.

As you said you have to nullify interval ID manually if you want to delete it.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top