# Custom event listener works once, then not again

**URL:** <https://forum.kirupa.com/t/custom-event-listener-works-once-then-not-again/332696>\
**Category:** flash\
**Created:** [October 3, 2014, 10:26pm UTC](https://forum.kirupa.com/t/custom-event-listener-works-once-then-not-again/332696 "2014-10-03T22:26:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpann](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tpann](https://forum.kirupa.com/u/tpann)\
**Post date:** [October 3, 2014, 10:26pm UTC](https://forum.kirupa.com/t/custom-event-listener-works-once-then-not-again/332696/1 "2014-10-03T22:26:11Z")

</div>

I have a class Manager that instantiates Tutorial. Tutorial dispatches events back up to Manager telling Manager to disable certain aspects of Manager at appropriate times. Specifically, Tutorial dispatches TutorialEvent.DISABLE\_BTN to disable a button during the duration of the tutorial.

I’m finding that the first time Tutorial dispatches DISABLE\_BTN it works just fine, but after that it doesn’t. Here are the highlights:

**TutorialEvent**

```php
public class TutorialEvent extends Event {
     public static const DISABLE_BTN:String = "disableBtn";
     ...
     public var params:Object;
     public function TutorialEvent(type:String, params:Object = null) {
          if (type == DISABLE_BTN) trace("TutorialEvent " + type);
          super(type);
          this.params = params;
     }
     public override function clone():Event {
          return new TutorialEvent(type, this.params);
     }
}

```

**Manager class**

```php

function newTutorial() {
     tutorial = new Tutorial();
     tutorial.addEventListener(TutorialEvent.DISABLE_BTN, disableBtn);
}
function disableBtn(t:TutorialEvent) {
     trace("Manager.disableBtn, t.params.action = " + t.params.action);
     if (t.params.action == "disable") button.disable();
}

```

**Tutorial class**

```php
...
     function step20():void {
          trace("Tutorial.step20: dispatching DISABLE_BTN");
          dispatchEvent(new TutorialEvent(TutorialEvent.DISABLE_BTN, {action:disable}));
     }
...

```

When I start the tutorial the first time, here’s the trace I get:

[FONT=courier new]Tutorial.step20: dispatching DISABLE\_BTN  
TutorialEvent disableBtn  
Manager.disableBtn, t.params.action = disable[/FONT]

…which is correct, and the button gets disabled. The NEXT time and all subsequent times I start the tutorial, here’s the trace:

[FONT=courier new]Tutorial.step20: dispatching DISABLE\_BTN  
TutorialEvent disableBtn[/FONT]

…and of course the button is not being disabled. I am not removing the DISABLE\_BTN listener at any point in Manager, and clearly the event is being dispatched. So why is disableBtn() listener not firing??

I should mention that TutorialEvent has over 70 types and up to this point I have had no problem with any of them.
