We (AS3 coders) all know that one of the great things about the AS3 event model is that handlers are scoped to their containing objects. I'm writing an EventDispatcher for JavaScript, and trying to achieve the same effect.
My question could be answered in a couple different ways:
A: How does ActionScript 3 set scope within an event handler to the handler's container object, rather than to the event handler's caller (the IEventDispatcher on whom dispatchEvent() was invoked)?
-or-
B: Is there a clean way to implement the Observer pattern, AS3/EventDispatcher-style, in JavaScript?