# Adding a box to the sketch pad

**URL:** <https://forum.kirupa.com/t/adding-a-box-to-the-sketch-pad/217196>\
**Category:** flash\
**Created:** [February 24, 2007, 1:08am UTC](https://forum.kirupa.com/t/adding-a-box-to-the-sketch-pad/217196 "2007-02-24T01:08:28Z")\
**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 24, 2007, 1:08am UTC](https://forum.kirupa.com/t/adding-a-box-to-the-sketch-pad/217196/1 "2007-02-24T01:08:28Z")

</div>

Hi there,

I have a simple drawing pad that works, but I want to allow the user to draw only in a certain area (only within the box).

\*\* My current code is:\*\*

this.createEmptyMovieClip(“your\_lines”, 100);  
var Drawing\_in\_progress:Boolean = false;

//sets up a mouse listener event  
var mouseListener:Object = new Object();  
mouseListener.onMouseDown = function() {  
// lineStyle(line width, hex color value, alpha)  
your\_lines.lineStyle(2, 0x00FF00, 100);  
// sets the current drawing position  
your\_lines.moveTo(\_xmouse, \_ymouse);  
Drawing\_in\_progress = true;  
};  
mouseListener.onMouseMove = function() {  
if (Drawing\_in\_progress == true) {  
//Draws a line using the current line style from the current drawing postion to (x,y)  
your\_lines.lineTo(\_xmouse, \_ymouse);  
updateAfterEvent();  
}  
};  
mouseListener.onMouseUp = function() {  
Drawing\_in\_progress = false;  
};  
Mouse.addListener(mouseListener);

// sets up button to delete all the lines  
delete\_lines.onRelease = function() {  
your\_lines.clear();  
};

Any help is appreciated. Thank you!
