# A fun problem with MouseEvent :O

**URL:** <https://forum.kirupa.com/t/a-fun-problem-with-mouseevent-o/297705>\
**Category:** Uncategorized\
**Created:** [October 7, 2009, 12:05pm UTC](https://forum.kirupa.com/t/a-fun-problem-with-mouseevent-o/297705 "2009-10-07T12:05:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![artheus](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@artheus](https://forum.kirupa.com/u/artheus)\
**Post date:** [October 7, 2009, 12:05pm UTC](https://forum.kirupa.com/t/a-fun-problem-with-mouseevent-o/297705/1 "2009-10-07T12:05:55Z")

</div>

Hey!

I just ran in to a little funny problem with MouseEvent!

What I did was to make a image-gallery class, and in that make a eventlistener for MouseEvent.Click for every individual image. And in the handler i’ve done a dispatchEvent. like this :

```auto

for(var i:int = 0; i < numImages; ++i) {
    image*.addEventListener(MouseEvent.CLICK, mouseClickHandler);
}

private function mouseClickHandler(e:MouseEvent):void
{
    dispatchEvent(e);
}

```

And then in the main-class I’ve made a listener for that, like this

```auto

imageGallery.addEventListener(MouseEvent.CLICK, mouseClickHandler);

private function mouseClickHandler(e:MouseEvent):void
{
    trace(e.target);
}

```

And what I get is multiple targets!

```auto

    [object imageGallery]
    [object image]

```

How do I make this access only one of these targets!? These don’t work:

```auto

    trace(e.target[0]);
    trace(e[0].target);

```

HELP!?

//Artheus
