Skip to content
richardszalay edited this page May 17, 2011 · 14 revisions

Creates an Observable sequence from the event values of an IEventDispatcher

static function fromEvent(dispatcher : IEventDispatcher, eventName : String, 
    useCapture : Boolean = false, priority : int = 0)

The useCapture and priority arguments will be used when adding an event listener to dispatcher.

Remarks

The event listener will be added when a subscription starts and removed if the subscription is cancelled.

The returned sequence does not complete

The returned sequence does not error

Marble Diagrams

event source  ──o───o───o───o──
                │   │   │   │
output        ──o───o───o───o──

Return Value

IObservable.<Event>

Examples

Observable.fromEvent(stage, MouseEvent.MOUSE_MOVE)
    .subscribe(function(event : MouseEvent) : void
    {
        trace("Mouse moved");
    });
Clone this wiki locally