# EventListener:Mouse\_Down malfunction?

**URL:** <https://forum.kirupa.com/t/eventlistener-mouse-down-malfunction/282455>\
**Category:** flash\
**Created:** [February 22, 2009, 1:18pm UTC](https://forum.kirupa.com/t/eventlistener-mouse-down-malfunction/282455 "2009-02-22T13:18:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hjalmarsn](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@hjalmarsn](https://forum.kirupa.com/u/hjalmarsn)\
**Post date:** [February 22, 2009, 1:18pm UTC](https://forum.kirupa.com/t/eventlistener-mouse-down-malfunction/282455/1 "2009-02-22T13:18:47Z")

</div>

Another problem… Trying to add event listeners to check whether my tiles are being pressed! This works excellent! They respond to the listeners BUT on the mose\_down/mouse\_up i canät trace the tile variables!!!

The listener functions:

```auto
function over(evt:MouseEvent):void {
    evt.target.alpha=.75;
    coordTxt.text="X: "+evt.target.myX+" Y: "+evt.target.myY;
}
function out(evt:MouseEvent):void {
    evt.target.alpha=1;
[COLOR=Red] trace(evt.target.myX);[/COLOR]//RETURNS CORRECT VALUE
    coordTxt.text="X: - Y: -";
}
function ner(evt:MouseEvent):void {
   [COLOR=Red] trace(evt.target.myX);[/COLOR]//RETURNS UNDEFINED
    if (evt.target.myX==0) {
        trace("dragging");
    } else {
        trace("not dragging");
        evt.target.alpha=0.5;
    }
}
function upp(evt:MouseEvent):void {
    trace("släppt!")
}

```

This is where I’ve added the listeners:

```auto

                    patch.name="tile"+k;
                    patch.x=-25-finito*25+50*i;
                    patch.y=-25-finito*25+50*j;
                    patch.myX = (X-(finito/2))+i;
                    patch.myY = ((finito/2)+Y)-j;
                    patch.myType=xy;
                    patch.addEventListener(MouseEvent.ROLL_OVER, MovieClip(root).over);
                    patch.addEventListener(MouseEvent.ROLL_OUT, MovieClip(root).out);
                    patch.addEventListener(MouseEvent.MOUSE_DOWN, MovieClip(root).ner);
                    patch.addEventListener(MouseEvent.MOUSE_UP, MovieClip(root).upp);
                    addChild(patch);

```
