Mouse draw with custom cursor

I have a problem with a whiteboard I’m creating.

When I add a custom cursor it won’t draw because when the mouse is down it’s referencing the cursor and not the board. So drawing doesn’t = true.

I can fix it by changing the eventlisteners to “stage” instead of “mBoard” but when I do that it will draw the the coordinates of where the mouse is on the cursor and the board.

So the Cursor could be x= 255 and y = 200 it will draw that coordinate but it will also draw the coordinate of where the mouse is over the cursor which could be x = 1 and y = 1. It will also draw that on the drawBoard.

Here are the examples in case I didn’t make myself clear.

example 1 [URL=“http://www.tweencreative.com/test02”] example 2

Here is the simplified code

package {

    import flash.display.*;
    import flash.events.*;
    import flash.ui.Mouse;


    public class Whiteboard extends Sprite {
        private var drawing:Boolean;
        private var drawBoard:Sprite =new Sprite;
        private var thickness:Number = 5;// Thickness of the markers
        private var dx:Number;
        private var dy:Number;
        private var mCursor:MovieClip= new Cursor();

        public function Whiteboard() {

            mBoard.mask=mMask;//mBorder mask
            mBoard.addChild(drawBoard);
            drawBoard.graphics.lineStyle(thickness,0x000000);
            addChild(mCursor);//Add marker to stage
            // if the mouse is inside the whiteboard the mouse cursor will be in the position of the mouse, if it isn't the mouse cursor will be in the center of the whiteboard
            if (mouseX > mBoard.x && mouseX < mBoard.x + mBoard.width && mouseY > mBoard.y && mouseY < mBoard.y + mBoard.height) {//Left, Right, Top, Bottom

                mCursor.x=mouseX;
                mCursor.y=mouseY;
            } else {
                mCursor.x=stage.width / 2;
                mCursor.y=stage.height / 2;
            }


            /*********************** Event handlers **********************/

            addEventListener(Event.ADDED_TO_STAGE,init);// Start When Whiteboard is added to the stage

            function init(evt:Event):void {

                mBoard.addEventListener(MouseEvent.MOUSE_DOWN,startDrawing);//Start Drawing
                mBoard.addEventListener(MouseEvent.MOUSE_MOVE,draws);// When Mouse Move, begin draw.
                stage.addEventListener(MouseEvent.MOUSE_UP,stopDrawing);// Mouse up, stop draw.
                stage.addEventListener(MouseEvent.MOUSE_MOVE,toggleMouse);// when mouse out of mBoard mouse will reappear 
            }

        }

        private function toggleMouse(evt:MouseEvent):void {

            if (mouseX > mBoard.x && mouseX < mBoard.x + mBoard.width && mouseY > mBoard.y && mouseY < mBoard.y + mBoard.height) {//Left, Right, Top, Bottom
                //we are inside the border sprite
                Mouse.hide();

            } else {
                //we are not inside border sprite
                Mouse.show();
            }
        }

        //Start Drawing
        private function startDrawing(evt:MouseEvent):void {

            dx=Math.round(evt.localX);// x coordinate of mouse
            dy=Math.round(evt.localY);// y coordinate of mouse
            drawing=true;
            drawBoard.graphics.moveTo(dx,dy);
        }

        private function draws(evt:MouseEvent):void {
            if (drawing) {

                dx=Math.round(evt.localX);// x coordinate of mouse
                dy=Math.round(evt.localY);// y coordinate of mouse
                mCursor.x=evt.stageX;
                mCursor.y=evt.stageY;
                trace("dx " + dx +", dy " + dy );
                //trace(evt.stageX)

                drawBoard.graphics.lineTo(dx,dy);

            }
            mCursor.x=evt.stageX;
            mCursor.y=evt.stageY;


        }
        public function stopDrawing(evt:MouseEvent):void {

            drawing=false;

        }

    }
}

Thanks

vxd