bendev
04-16-2005, 08:32 PM
hello,
So, there is a main loop with a setTimeout inside - it's made to move some DIVs the one after the other :
function Mainfunc() {
for (i = 0; i < top.parent.gauche.stageId[num_div].length ; i++) {
....
if (i> 0)
timerMain=setTimeout('goDown('+num_div+', '+i+')', 1200) ;
else
goDown(num_div, i) ;
}
}
as you understand, I don't need to wait the very first time, then I need to wait because inside the goDown function, I call an other function with a loop and a setTimeout() inside ;
The goDown() function is made to move one DIV from one point to an other ....
function goDown((num_div, i) {
.....
Perform_Anim()
}
Perform_Anim() {
if(timer) clearTimeout(timer) ;
moveAreaAny(speed1,speed2)
}
function moveAreaAny(moveH,moveV){
....
// This is in a loop :
// ===========
this.moveArea(x,y)
timer=setTimeout(this.obj+".any("+moveH+","+moveV+")",retard)
}
I hope,this description is not too fine but that's how it works, basically
So, the 2nd loop of setTimeout is OK ... it takes around 1 second to perform this loop and this is the reason why I wait 1.2 seconds in the first setTimeout before calling the function goDown the 2nd time ...
what happens :
_ one DIV to move = one call of the goDown() function => OK
_ 2 DIVs to move : one call of the goDown() function + wait 1.2 second and then the second call of goDown() is OK too ...
_ more than 2 DIVS to move => big mess ! I've tried to clearTimeout(timerMain) at the end of the goDown() function but that's stop completely the programm ... How can I do ? maybe in giving different names to the mainTimer ? but how ? why do the 2nd loop work and not the first ?
Thank you by advance for any help
Ben
So, there is a main loop with a setTimeout inside - it's made to move some DIVs the one after the other :
function Mainfunc() {
for (i = 0; i < top.parent.gauche.stageId[num_div].length ; i++) {
....
if (i> 0)
timerMain=setTimeout('goDown('+num_div+', '+i+')', 1200) ;
else
goDown(num_div, i) ;
}
}
as you understand, I don't need to wait the very first time, then I need to wait because inside the goDown function, I call an other function with a loop and a setTimeout() inside ;
The goDown() function is made to move one DIV from one point to an other ....
function goDown((num_div, i) {
.....
Perform_Anim()
}
Perform_Anim() {
if(timer) clearTimeout(timer) ;
moveAreaAny(speed1,speed2)
}
function moveAreaAny(moveH,moveV){
....
// This is in a loop :
// ===========
this.moveArea(x,y)
timer=setTimeout(this.obj+".any("+moveH+","+moveV+")",retard)
}
I hope,this description is not too fine but that's how it works, basically
So, the 2nd loop of setTimeout is OK ... it takes around 1 second to perform this loop and this is the reason why I wait 1.2 seconds in the first setTimeout before calling the function goDown the 2nd time ...
what happens :
_ one DIV to move = one call of the goDown() function => OK
_ 2 DIVs to move : one call of the goDown() function + wait 1.2 second and then the second call of goDown() is OK too ...
_ more than 2 DIVS to move => big mess ! I've tried to clearTimeout(timerMain) at the end of the goDown() function but that's stop completely the programm ... How can I do ? maybe in giving different names to the mainTimer ? but how ? why do the 2nd loop work and not the first ?
Thank you by advance for any help
Ben