all groups > flash actionscript > june 2005 >
You're in the

flash actionscript

group:

clearInterval() doesn?t work


clearInterval() doesn?t work paulo fabiano
6/29/2005 9:18:26 PM
flash actionscript:
Hi everybody,

i?m having some problems with setInterval() and clearInterval()

i?m doing like this..

function progress() {
...
clearInterval();
}

function init() {
...
setInterval("progress", 1);

}

I?ve already tried to use variable = setInternal(...) and
clearInterval(variable)

but also doesn?t work...
what can it be?


thanksss
[]?s
Re: clearInterval() doesn?t work NSurveyor
6/29/2005 9:37:00 PM
Your code should something like this:

function progress(){
trace('Hi!');
clearInterval(intervalID);
}
function init(){
intervalID =setInterval(progress,1);
}
init();

When this is run, progress will be called after 1 milliseconds, and then it
won't be called again. Why do that, when you canjust use:

progress();

Can you explain what you are trying to achieve?
Re: clearInterval() doesn?t work Jeckyl
6/30/2005 12:00:00 AM
nicer code, so you don't have a variable left lying around that you need to
ensure doesn't disappear or get overwritten, is:

[quoted text, click to view]
function progress (myinterval) {
trace ('Hi!');
clearInterval (myinterval.id);
}
function init () {
var myinterval = new Object;
myinterval.id = setInterval (progress, 1, myinterval);
}
init ();
[quoted text, click to view]

or better, to avoid having a function 'progress' exposed that you only want
to call from the interval...
[quoted text, click to view]
function init () {
var myinterval = new Object;
myinterval.id = setInterval (
function (myinterval) {
trace ('Hi!');
clearInterval (myinterval.id);
}
, 1, myinterval);
}
init ();
[quoted text, click to view]

but NSurveyor's question still applies .. what's the point of a 1
millisecond delay?
--
Jeckyl

Re: clearInterval() doesn?t work paulo fabiano
7/1/2005 12:45:26 PM
Hi guys..
it?s working now...the problem was the "" in the name of the function...
i used setInterval(progress, 1) and worked... :)

and I was using ("progress", 1)...

Re: clearInterval() doesn?t work NSurveyor
7/1/2005 1:19:03 PM
AddThis Social Bookmark Button