Mouse Drawing with an Eraser

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.

Download

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.

Back to Basic Tutorials              Back to Flash and Math Home

We welcome your comments, suggestions, and contributions. Click the Contact Us link below and email one of us.

Adobe®, Flash®, ActionScript®, Flex® are registered trademarks of Adobe Systems Incorporated.