In html5/canvas the below code (I just gave a snippet of working code) animates a few images based on time. Something like a Flash animation where at certain times images start to move at certain times or frame count. My question is , is there a better way to do this ? I know I can use something other than setInterval . I am calculating the elapsed time and setting off images based on the time interval.

function doGameLoop() {
		now = new Date();
        totalSeconds = (now - start) / 1000;
        last = now;
		ctx.fillText("totalSeconds=" +totalSeconds ,10,100);
		if (totalSeconds>2 && totalSeconds<6)
		if (totalSeconds>4 && totalSeconds<8)
		if (totalSeconds>10){
			start = new Date();//start again
      //  fi++;

	var img= new ClassLoadImages(30,30);
	var img2= new ClassLoadImages(30,30);
	var img3= new ClassLoadImages(30,30);