# Custom Event can't be recasted second time called

**URL:** <https://forum.kirupa.com/t/custom-event-cant-be-recasted-second-time-called/325014>\
**Category:** flash\
**Created:** [September 21, 2011, 1:09pm UTC](https://forum.kirupa.com/t/custom-event-cant-be-recasted-second-time-called/325014 "2011-09-21T13:09:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nook](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@nook](https://forum.kirupa.com/u/nook)\
**Post date:** [September 21, 2011, 1:09pm UTC](https://forum.kirupa.com/t/custom-event-cant-be-recasted-second-time-called/325014/1 "2011-09-21T13:09:07Z")

</div>

I have a base class for buttons which handles button basics like mouse listeners etc.  
Now I’m trying to extend it to also have the possibility to store an event (yes event, not event type) that is supposed to be dispatched on click.

So I have my _CustomEvent_ (extending _Event_) that I pass into the base class and store it with type _Event_.  
Outside, in the event listener I have an event argument typed as _CustomEvent_.  
First time I click it works fine and _event is CustomEvent_ traces \*true \*in the event handler.  
But the second time I click, _event is CustomEvent_ traces \*false \*and I get the “type coercion failed” error (cannot convert Event to CustomEvent):

```auto
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@29d3b7e1 to com.package.events.CustomEvent.
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.package.display.buttons::ButtonBase/onClick()

```

If I trace \*event is CustomEvent \*in the base class before the event is dispatched it always traces _true_.

So it seems something happens to the event in the dispatcher functions, but what boggles me is that the base class always sees the event as \*CustomEvent \*while the event listener thinks it is \*CustomEvent \*first time only.

Anybody know why?

I know this approach is not the best architecture wise, but I still thinks it’s a bit weird and would like to understand it better.
