# Adding an eraser

**URL:** <https://forum.kirupa.com/t/adding-an-eraser/216327>\
**Category:** flash\
**Created:** [February 15, 2007, 2:43pm UTC](https://forum.kirupa.com/t/adding-an-eraser/216327 "2007-02-15T14:43:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wispas](https://avatars.discourse-cdn.com/v4/letter/w/9de0a6/32.png) [@wispas](https://forum.kirupa.com/u/wispas)\
**Post date:** [February 15, 2007, 2:43pm UTC](https://forum.kirupa.com/t/adding-an-eraser/216327/1 "2007-02-15T14:43:35Z")

</div>

Hi there, I have a sketch pad and it works and everything, but I need like an eraser to be added on. Anyone keen on taking a look? Any help is appreciated. Thank you!

(See the attached file)

**Here is the code:**

lineThickness = 0;  
selectedColor = “0x000000”;  
\_root.onMouseDown = startDrawing;  
\_root.onMouseUp = stopDrawing;  
function startDrawing() {  
if (\_xmouse\<455) {  
\_root.lineStyle(lineThickness, selectedColor);  
\_root.moveTo(\_root.\_xmouse, \_root.\_ymouse);  
\_root.onMouseMove = drawLine;  
}  
this.attachMovie(“cursor\_id”, “cursor\_mc”, this.getNextHighestDepth(),  
{\_x:\_xmouse, \_y:\_ymouse});  
Mouse.hide();  
var mouseListener:Object = new Object();  
mouseListener.onMouseMove = function() {  
pencil.\_x = \_xmouse;  
pencil.\_y = \_ymouse;  
updateAfterEvent();  
};

Mouse.addListener(mouseListener);

this.createEmptyMovieClip(“drawing\_mc”, this.getNextHighestDepth());  
var mouseListener:Object = new Object();  
mouseListener.onMouseDown = function() {  
this.drawing = true;  
drawing\_mc.moveTo(\_xmouse, \_ymouse);  
};

mouseListener.onMouseUp = function() {  
this.drawing = false;  
};

mouseListener.onMouseMove = function() {  
if (this.drawing) {  
drawing\_mc.lineTo(\_xmouse, \_ymouse);  
}  
updateAfterEvent();  
};

Mouse.addListener(mouseListener);

var keyListener:Object = new Object();  
keyListener.onKeyDown = function() {  
if (Key.isDown(Key.DELETEKEY) || Key.isDown(Key.BACKSPACE)) {  
drawing\_mc.clear();  
}

};

Key.addListener(keyListener);

}  
function drawLine() {  
\_root.lineTo(this.\_xmouse, this.\_ymouse);  
}  
function stopDrawing() {  
delete this.onMouseMove;  
}  
line0.onPress = function() {  
lineThickness = 0;  
};  
line3.onPress = function() {  
lineThickness = 3;  
};  
line6.onPress = function() {  
lineThickness = 6;  
};  
line9.onPress = function() {  
lineThickness = 9;  
};  
line12.onPress = function() {  
lineThickness = 12;  
};  
colorRed.onPress = function() {  
selectedColor = “0xFF0000”;  
};  
colorGreen.onPress = function() {  
selectedColor = “0x00FF00”;  
};  
colorOrange.onPress = function() {  
selectedColor = “0xff9900”;  
};  
colorBlue.onPress = function() {  
selectedColor = “0x00FFFF”;  
};  
colorYellow.onPress = function() {  
selectedColor = “0xFFFF00”;  
};  
colorDblue.onPress = function() {  
selectedColor = “0x0000FF”;  
};  
colorPink.onPress = function() {  
selectedColor = “0xFF00FF”;  
};  
colorPurple.onPress = function() {  
selectedColor = “0x6633CC”;  
};  
colorBlack.onPress = function() {  
selectedColor = “0x000000”;  
};
