November 2011
Intermediate to advanced
348 pages
7h 2m
English
In this recipe, we'll attach event listeners to images. As we can only attach event listeners to paths with our Events class, and as images drawn on the canvas aren't classified as paths, we can create a rectangular region that overlays an image in order to attach event listeners to the rectangular region, and consequently attach event listeners to the image.

Follow these steps to draw two different images and then attach mouseover, mouseout, mousedown, and mouseup event listeners to them:
Events class:<script src="events.js"> </script>
writeMessage() function which writes ...Read now
Unlock full access