# Event Listener - Weak References

**URL:** https://forum.kirupa.com/t/event-listener-weak-references/314327
**Category:** flash
**Created:** [September 24, 2010, 6:36pm UTC](https://forum.kirupa.com/t/event-listener-weak-references/314327 "2010-09-24T18:36:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![TomAuger](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@TomAuger](https://forum.kirupa.com/u/TomAuger)
#### Post date: [September 24, 2010, 6:36pm UTC](https://forum.kirupa.com/t/event-listener-weak-references/314327/1 "2010-09-24T18:36:39Z")

</div>

Hi Guys, I’m having trouble understanding the weak reference flag with addEventListener() - specifically, using it seems to cause my listener to not fire. It surely has something to do with how everything is set up:

1. I am calling a class called “ScrollBar”. This class does NOT extend movieclip, but its constructor takes a reference to a scrollbarMC movie clip.

2. this ScrollBar class adds an event listener on the scrollbar MC like this:  
\_scrollbar.addEventListener(MouseEvent.MOUSE\_DOWN, onScrollBarDown, false, 0, true);

3. my event handler looks like this:  
function onScrollBarDown( e : Event ) {  
trace(“mouse down!”);  
}

With the weak reference flag set, this handler never fires.

If I clear that flag (see below), the handler fires as expected  
\_scrollbar.addEventListener(MouseEvent.MOUSE\_DOWN, onScrollBarDown, false, 0);

What’s up with that?

I don’t truly understand what I’m dealing with here, but I want to make sure my class cleans up after itself, and I won’t have the opportunity to call some kind of destructor method that removes the event listeners (easily).

Thanks for your help!

– Tom
