# Please help me complete this code

**URL:** <https://forum.kirupa.com/t/please-help-me-complete-this-code/242960>\
**Category:** flash\
**Created:** [November 1, 2007, 1:52am UTC](https://forum.kirupa.com/t/please-help-me-complete-this-code/242960 "2007-11-01T01:52:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nykol86](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@nykol86](https://forum.kirupa.com/u/nykol86)\
**Post date:** [November 1, 2007, 1:52am UTC](https://forum.kirupa.com/t/please-help-me-complete-this-code/242960/1 "2007-11-01T01:52:29Z")

</div>

Hello,  
With the help of some nice people I now have a Flash paint program.

[http://www.kirupa.com/forum/showthread.php?t=279206](http://www.kirupa.com/forum/showthread.php?t=279206)

My next step is to incorporate this program into another little Flash movie.  
I pasted the following code in the first frame of a movie clip.  
This movie clip is my ‘canvas’,  
i.e. the borders that the paint application must stay within.  
What can I add to this code to give it the movie clip’s dimensions of 500 x 375 pixels?  
Also, I want to add some sort of button that clears the paint.

Thanks,  
Nicole

```auto
import flash.display.Sprite;
import flash.events.MouseEvent;

var brush:Sprite = new Sprite();
addChild (brush);

initCanvas ();

function initCanvas ():void
{
    stage.addEventListener (MouseEvent.MOUSE_DOWN, startPainting);
    stage.addEventListener (MouseEvent.MOUSE_UP, stopPainting);
}
function startPainting (me:MouseEvent):void
{
    brush.graphics.lineStyle (randRange(2, 5), Math.random() * 0xFFFFFF);
    brush.graphics.moveTo (stage.mouseX, stage.mouseY);
    stage.addEventListener (MouseEvent.MOUSE_MOVE, paint);
}

function paint (me:MouseEvent):void
{
    brush.graphics.lineTo (stage.mouseX, stage.mouseY);
}

function stopPainting (me:MouseEvent):void
{
    stage.removeEventListener (MouseEvent.MOUSE_MOVE, paint);
}

function randRange (min:Number, max:Number):Number
{
    return Math.random() * max - min + 1 + min;
}

```
