# Mouse Handler

**URL:** <https://forum.kirupa.com/t/mouse-handler/251723>\
**Category:** flash\
**Created:** [February 12, 2008, 1:40am UTC](https://forum.kirupa.com/t/mouse-handler/251723 "2008-02-12T01:40:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mleep](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@mleep](https://forum.kirupa.com/u/mleep)\
**Post date:** [February 12, 2008, 1:40am UTC](https://forum.kirupa.com/t/mouse-handler/251723/1 "2008-02-12T01:40:28Z")

</div>

so i have a really simple program that simply draws a rectangle, and lets the user move the rectangle around the scene with the mouse. except its not working, no errors.

the problem is, when i click and drag around the scene - nothing happens.

```auto
var container_mc:MovieClip;
var width:Number = 100;
var height:Number = 60;

container_mc = this.createEmptyMovieClip( "boxContainer", this.getNextHighestDepth() );
container_mc.clear(); // Clear the previous box rendering.
container_mc.lineStyle( 1, 0x000000, 100 ); // Use a 1 point black line.
container_mc.beginFill( 0x0FFFFF, 100 ); // Start a white fill.
container_mc.moveTo(0, 0); // Position the drawing pen.
container_mc.lineTo( width, 0 ); // Draw the border of the box.
container_mc.lineTo( width, height );
container_mc.lineTo( 0, height );
container_mc.lineTo( 0, 0 );
container_mc.endFill(); // Formally stop filling the shape.

var mouseListener:Object = new Object();

mouseListener.onMouseDown = function() {
    this.orig_x = _xmouse; // store position of rectangle
    this.orig_y = _ymouse;
};
mouseListener.onMouseMove = function() {
    this.container_mc.moveTo(this.orig_x, this.orig_y);
    updateAfterEvent();
};

mouseListener.onMouseUp = function() {
    this.orig_x = _xmouse; // store position of rectangle
    this.orig_y = _ymouse;
};

Mouse.addListener(mouseListener);

```
