A program that will let the user to draw a rectangle

Hi, I’ve been trying to write a simple program that would let the user draw a rectangle, like for example in Paint etc. Could someone please tell me what is wrong with my code? When i compile, it won’t create a rectangle at all.

Here’s the source:

package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;

public class myRect extends MovieClip
{
    var xx:int=0;
    var yy:int=0;
    var rect:MovieClip=new MovieClip();
    public function myRect()
    {
        stage.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDownRect,false,0,true);
        stage.addEventListener(MouseEvent.MOUSE_UP,onMouseUpRect,false,0,true);
        addChild(rect);
    }
    private function onMouseDownRect(evt:MouseEvent):void
    {
        stage.removeEventListener(MouseEvent.MOUSE_DOWN,onMouseDownRect);
        rect.graphics.beginFill(0xFF0000);
        rect.graphics.drawRect(mouseX,mouseY,0,0);
        xx=mouseX;yy=mouseY;
        stage.addEventListener(Event.ENTER_FRAME,onLoop,false,0,true);
    }
    private function onMouseUpRect(evt:MouseEvent):void
    {
        rect.graphics.endFill();
        stage.removeEventListener(Event.ENTER_FRAME,onLoop);
    }
    private function onLoop(evt:Event):void
    {
        rect.width=mouseX-xx;
        rect.height=mouseY-yy;
        addChild(rect);
    }
}

}