One of our Discussion Forum members suggested that we follow up on our 'Drawing with the Mouse' tutorial and add an eraser to the mix. Such an additon requires a more complex interplay between event handlers. It also requires constructing a custom mouse pointer. Below is a finished applet. The user can draw as well as activate the eraser to erase. The size od the eraser changes when the thickness of the line changes. We discuss the code on the next page. On the last page, we extract and present only the code needed for a custom mouse pointer and show the corresponding simplified applet.
- Flash CS3 file draw_part2_1.fla
Download the well-commented fla file for the swf displayed above.
On the next page of this tutorial, we discuss the code behind the applet, in particular, the new elements in the code.