Why the timer stops, vypolnenii 1 time

The question was asked: 49 years 8 months ago   views: 5
0

Hello, help with a timer

When moving the mouse cursor is checked if the coordinate of the cursor according to x less than 50, the variable dx is reduced until, until the variable OutOfRangeне will not be equal to "OOR_N" (use the timer setInterval), but as a result of executing the code inside the timer is executed once, what is my mistake?

canvas.onmousemove = mouseMove; function mouseMove(event){ movecur(); } movecur function(){ var OutOfRange; if(curx<=50){ OutOfRange="OOR_Y"; ChangeCanv function() { timer1 = setInterval(Change(), 400); } function Change() { dx=dx-10; alert(dx); build(); if (OutOfRange=="OOR_N"){ clearInterval(timer1); } } ChangeCanv(); } build(); }
Asked: 01-01-1970 в 03:00:00
var OutOfRange is a Great name for a variable! Function can not be confused. - 23-12-2012 в 15:53:27

Answers   1

0

you distinguish a function call from her AMNI?

setInterval(Change(), 400);

you called the function and passed undefined to setInterval

and had:

setInterval(Change, 400);
Answered: 23-12-2012 в 15:07:22