> Yeah, its funny how such a language construct actually is implemented in > Firefox without the world knowing. Chrome/Opera and IE have nothing alike. > However: It will not become standard before the release of IE10 and > therefore will take - estimate at least more 5 years > until it can be safely used in the JavaScript context - rough estimate.
That's certainly true. >> Not all listeners have to be weak references. > > class MyButton extends Sprite { > public function MyButton() { > addEventListener(MouseEvent.MOUSE_OVER, handleMouseOver); > } > } > > This is a very simple and common case of a event that is not possible to be > fixed without weak listeners. How so? As far as I can tell (assuming that handleMouseOver is an instance method), the only references to the listener are that of the instance itself to its member method, and that of the instance itself (per its EventDispatcher ancestry) to the listener passed in. As long as the instance exists (i.e., is not eligible for GC), it holds a strong reference to its own method, so it does not matter whether or not a weak reference is passed to the addEventListener (unless I misunderstand the internals of addEventListener and that reference is actually passed around and copied elsewhere). If the instance *is* eligible for GC, so is the method, since the instance holds the only two references to it.