PDA

View Full Version : Progress Bar for setInterval?



mx_kid
November 30th, 2005, 12:21 PM
is it possible to create a progress bar which shows the progress of a setInterval?

so if ive used setInterval(foo, 4000); it will "load" up to each function call...

stringy
November 30th, 2005, 06:35 PM
is it possible to create a progress bar which shows the progress of a setInterval?

so if ive used setInterval(foo, 4000); it will "load" up to each function call...

progress bar instance name bar


bar._xscale = 0;
function foo(arg) {
trace(arg);
}
var boo = this;
function myfunction(func, arg, t) {
mi2 = setInterval(function () {
bar._xscale += 1;
updateAfterEvent();
if (bar._xscale>=100) {
bar._xscale = 0;
clearInterval(mi2);
boo[func](arg);
}
}, t/100);
}
myfunction("foo", "coo", 4000);

NiñoScript
November 30th, 2005, 06:47 PM
what about making it like this:


timer=0;
fooInterval = setInterval(function(){
timer++;
if(timer==100){
foo();
clearInterval(fooInterval)
}
}, 40);

senocular
November 30th, 2005, 06:52 PM
progress bar instance name bar

I must say, I'm pretty impressed. It took me a second to see what you were doing, but then it all made sense ;)

stringy
December 1st, 2005, 08:58 AM
I must say, I'm pretty impressed. It took me a second to see what you were doing, but then it all made sense ;)
Thanks :D
A whole second? You must be slipping up. ;)

senocular
December 1st, 2005, 09:09 AM
Thanks :D
A whole second? You must be slipping up. ;)
I was confused until I saw t/100 - and Im a slow reader :beam:

mx_kid
December 1st, 2005, 05:25 PM
ace thanks for your help, works a charm :thumb2:

stringy
December 1st, 2005, 05:32 PM
ace thanks for your help, works a charm :thumb2:
you are welcome