Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Listens to an event on the given object and returns a reporter function
- * that returns true if the event has been called.
- *
- * @example
- * <p>
- * The following example creates a simple <code>DropDown</code> instance. The dropdown uses event listeners to capture
- * user interaction.
- * </p>
- * <listing>
- var dispatcher:EventDispatcher = new Sprite();
- var spy:Function = TestUtil.spy(dispatcher, Event.OPEN);
- trace(spy()); // false;
- dispatcher.dispatchEvent(Event.OPEN);
- trace(spy()); // true;
- * </listing>
- */
- public static function spyOnEvent(eventTarget : EventDispatcher, eventType : String) : Function
- {
- var didFire : Boolean = false;
- eventTarget.addEventListener( eventType, function(e : Event) : void
- {
- if (e.type == eventType)
- {
- didFire = true;
- }
- } );
- return function() : Boolean
- {
- return didFire;
- };
- };
Add Comment
Please, Sign In to add comment