i'm trying js animations, , have animated box moves within borders, animation stop when box hits 1 of borders. 1 of functions use:
function animmoveright() { var interval = setinterval("moveright(10)", 40); if (hitright == true) { clearinterval(interval); } }
the moveright(10)
changes box'position 10 pixels right. hitright
set true when box hits right border. well, obviously, code doesn't work, keeps on looping moveright()
function. now, question is, how cancel interval within animmoveright()
function?
function animmoveright() { var interval; function fnc(){ if (hitright == true) { window.clearinterval(interval); } else{ moveright(10); } } interval = setinterval(fnc, 40); }
Comments
Post a Comment