# Wanted: better code to dispatch custom event from mouse click

**URL:** <https://forum.kirupa.com/t/wanted-better-code-to-dispatch-custom-event-from-mouse-click/303501>\
**Category:** flash\
**Created:** [January 21, 2010, 9:22am UTC](https://forum.kirupa.com/t/wanted-better-code-to-dispatch-custom-event-from-mouse-click/303501 "2010-01-21T09:22:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaedo](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@Shaedo](https://forum.kirupa.com/u/Shaedo)\
**Post date:** [January 21, 2010, 9:22am UTC](https://forum.kirupa.com/t/wanted-better-code-to-dispatch-custom-event-from-mouse-click/303501/1 "2010-01-21T09:22:53Z")

</div>

Is there a better way of doing this?

```auto
var b:someButton = new someButton();
b.addEventListener(MouseEvent.CLICK, dispatchEvent, false, 0, true);

function dispatchEvent(e:MouseEvent):void
{
     dispatchEvent(new Event('SomeEvent',true));
}

```

I feel I should be able to remove the function and just have the click dispatch my custom event? Is this possible?

Thank you for your consideration,  
S.
