Re: ACTION-57 done

I like the idea of having a fairly complete example like this. 
Following are just some nit-picky comments about the code.

> var color = ["red","blue"];

You'll get an exception if there are >2 touch points.


> //	canvas.addEventListener("touchstart", touchStart, false);
> 	canvas.addEventListener("touchmove", touchMove, false)
> 	canvas.addEventListener("mousemove", mouseMove, false);

There's no mouseMove or touchStart function defined.  (The touchStart 
line is commented out, but the mouseMove one is not.)

> 	/*
> 	* draw the square with different color for each touch
> 	*/
> 	for (i=0; i<ev.touches.length; i++) {
> 		draw(oldX[i], oldY[i], "white");		// erase last position

You should first erase all squares, then draw all squares.  Otherwise 
you might erase part of a square after it's drawn, if it overlaps with 
another square.

> 		draw(ev.changedTouches[i].pageX, ev.changedTouches[i].pageY, color[i]);

This assumes that changedTouches.length == touches.length, and that the 
each touch will retain the same index in the list from one event to the 
next.  Neither of these is guaranteed by the spec.

> function touchCancel() {
> 	ctx.fillStyle="white";
> 	ctx.fillRect(0,0,640,960);	// clear the canvas
> }

This function is not actually called anywhere.  It's also a little 
strange that you would do something like this on touchcancel but not 
touchend, since the spec leaves it mostly implementation-defined when 
touchcancel happens -- it won't be predictable from one device or 
browser to the next.

Received on Tuesday, 9 August 2011 15:49:08 UTC