Drawing API

I have added a little to some code that another user had written for drawing a square, but I have some question. As of now when the user clicks and drags on the stage you draw a square. I have it so you can change the color and stroke color of the square. Here is what I want to do. Instead of the user clicking and dragging on the stage I want them to first click a button that represents the object to be drawn and then that activates the code to draw the rectangle as the click and drag on the stage. Here is the code:

ActionScript Code:
[LEFT][COLOR=#993300]import[/COLOR] flash.[COLOR=#000000]display[/COLOR].[COLOR=#000000]Sprite[/COLOR];

[COLOR=#993300]import[/COLOR] flash.[COLOR=#000000]events[/COLOR].[COLOR=#000000]MouseEvent[/COLOR];
[COLOR=#993300]import[/COLOR] flash.[COLOR=#000000]display[/COLOR].[COLOR=#993300]MovieClip[/COLOR];
[COLOR=#993300]import[/COLOR] flash.[COLOR=#000000]display[/COLOR].[COLOR=#993300]Stage[/COLOR];
[COLOR=#993300]import[/COLOR] fl.[COLOR=#000000]controls[/COLOR].[COLOR=#000000]ColorPicker[/COLOR];
[COLOR=#993300]import[/COLOR] fl.[COLOR=#000000]events[/COLOR].[COLOR=#000000]ColorPickerEvent[/COLOR];

[COLOR=#993300]var[/COLOR] mouseIniX:[COLOR=#993300]Number[/COLOR];
[COLOR=#993300]var[/COLOR] mouseIniY:[COLOR=#993300]Number[/COLOR];

[COLOR=#993300]var[/COLOR] chosenColour:uint = [COLOR=#000000]0[/COLOR];
[COLOR=#993300]var[/COLOR] chosenColour2:uint = [COLOR=#000000]0[/COLOR];

[COLOR=#F000F0]// This will hold a reference to the current created object[/COLOR]
[COLOR=#F000F0]// on the onMouseDownEvent and is going to be used to create shape[/COLOR]
[COLOR=#993300]var[/COLOR] mcRef:[COLOR=#993300]MovieClip[/COLOR];

fCP.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]ColorPickerEvent.[COLOR=#000000]CHANGE[/COLOR], changeHandler[COLOR=#000000])[/COLOR];
sCP.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]ColorPickerEvent.[COLOR=#000000]CHANGE[/COLOR], changeHandler2[COLOR=#000000])[/COLOR];

[COLOR=#993300]stage[/COLOR].[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]MOUSE_DOWN[/COLOR], onMouseDownHandler[COLOR=#000000])[/COLOR];
[COLOR=#993300]stage[/COLOR].[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]MOUSE_UP[/COLOR], onMouseUpHandler[COLOR=#000000])[/COLOR];

[COLOR=#993300]function[/COLOR] changeHandlerCOLOR=#000000[/COLOR]:[COLOR=#993300]void[/COLOR] [COLOR=#000000]{[/COLOR]
chosenColour = event.[COLOR=#000000]currentTarget[/COLOR].[COLOR=#000000]selectedColor[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#993300]function[/COLOR] changeHandler2COLOR=#000000[/COLOR]:[COLOR=#993300]void[/COLOR] [COLOR=#000000]{[/COLOR]
chosenColour2 = event.[COLOR=#000000]currentTarget[/COLOR].[COLOR=#000000]selectedColor[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#F000F0]// Functions to handle object dragging[/COLOR]
[COLOR=#993300]function[/COLOR] startDragingCOLOR=#000000[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#993300]e[/COLOR].[COLOR=#993300]target[/COLOR].[COLOR=#993300]startDrag[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#993300]function[/COLOR] stopDragingCOLOR=#000000[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#993300]e[/COLOR].[COLOR=#993300]target[/COLOR].[COLOR=#993300]stopDrag[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#993300]function[/COLOR] onMouseDownHandlerCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR] [COLOR=#993300]e[/COLOR].[COLOR=#993300]target[/COLOR] is [COLOR=#993300]Stage[/COLOR] [COLOR=#000000])[/COLOR]
[COLOR=#000000]{[/COLOR]
mouseIniX = mouseX;
mouseIniY = mouseY;

    [COLOR=#F000F0]*// Create our new square and add some listeners to it to enabled dragging*[/COLOR]
    [COLOR=#993300]var[/COLOR] mc:[COLOR=#993300]MovieClip[/COLOR] = [COLOR=#993300]new[/COLOR] [COLOR=#993300]MovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    mc.[COLOR=#000000]buttonMode[/COLOR] = [COLOR=#993300]true[/COLOR];
    mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]MOUSE_DOWN[/COLOR], startDraging[COLOR=#000000])[/COLOR];
    mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]MouseEvent.[COLOR=#000000]MOUSE_UP[/COLOR], stopDraging[COLOR=#000000])[/COLOR];
    addChild[COLOR=#000000]([/COLOR] mc [COLOR=#000000])[/COLOR];
    [COLOR=#F000F0]*// Hold a reference so we can update its graphics using the drawing API*[/COLOR]
    mcRef = mc;
    
    [COLOR=#F000F0]*// DRAW!*[/COLOR]
    [COLOR=#993300]stage[/COLOR].[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000000]ENTER_FRAME[/COLOR], square[COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]}[/COLOR]

[COLOR=#993300]function[/COLOR] onMouseUpHandlerCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]stage[/COLOR].[COLOR=#000000]removeEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000000]ENTER_FRAME[/COLOR], square[COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#993300]function[/COLOR] squareCOLOR=#000000[/COLOR]:[COLOR=#993300]void[/COLOR]
[COLOR=#000000]{[/COLOR]
mcRef.[COLOR=#000000]graphics[/COLOR].[COLOR=#993300]clear[/COLOR]COLOR=#000000[/COLOR];
mcRef.[COLOR=#000000]graphics[/COLOR].[COLOR=#993300]lineStyle[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]1[/COLOR], chosenColour2, [COLOR=#000000]1[/COLOR].[COLOR=#000000]0[/COLOR][COLOR=#000000])[/COLOR];
mcRef.[COLOR=#000000]graphics[/COLOR].[COLOR=#993300]beginFill[/COLOR][COLOR=#000000]([/COLOR]chosenColour, [COLOR=#000000]1[/COLOR].[COLOR=#000000]0[/COLOR][COLOR=#000000])[/COLOR];
mcRef.[COLOR=#000000]graphics[/COLOR].[COLOR=#000000]drawRect[/COLOR][COLOR=#000000]([/COLOR]mouseIniX, mouseIniY, mouseX - mouseIniX, mouseY - mouseIniY[COLOR=#000000])[/COLOR];
mcRef.[COLOR=#000000]graphics[/COLOR].[COLOR=#993300]endFill[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]

I am just frustrated because I have tried changing the code up and can not seem to figure it out. Please, can someone help me. Here is a link to how it works as well. The square button as of now does not work, which is what I am trying to figure out.

http://www.pbk.com/draw/fromMario3.html