// ================================================================================================= // // Starling Framework // Copyright Gamua GmbH. All Rights Reserved. // // This program is free software. You can redistribute and/or modify it // in accordance with the terms of the accompanying license agreement. // // ================================================================================================= package starling.events { import flash.utils.Dictionary; import starling.core.starling_internal; import starling.display.DisplayObject; use namespace starling_internal; /** The EventDispatcher class is the base class for all classes that dispatch events. * This is the Starling version of the Flash class with the same name. * *
The event mechanism is a key feature of Starling's architecture. Objects can communicate * with each other through events. Compared the the Flash event system, Starling's event system * was simplified. The main difference is that Starling events have no "Capture" phase. * They are simply dispatched at the target and may optionally bubble up. They cannot move * in the opposite direction.
* *As in the conventional Flash classes, display objects inherit from EventDispatcher * and can thus dispatch events. Beware, though, that the Starling event classes are * not compatible with Flash events: Starling display objects dispatch * Starling events, which will bubble along Starling display objects - but they cannot * dispatch Flash events or bubble along Flash display objects.
* * @see Event * @see starling.display.DisplayObject DisplayObject */ public class EventDispatcher { private var _eventListeners:Dictionary; /** Helper object. */ private static var sBubbleChains:Array = []; /** Creates an EventDispatcher. */ public function EventDispatcher() { } /** Registers an event listener at a certain object. */ public function addEventListener(type:String, listener:Function):void { if (_eventListeners == null) _eventListeners = new Dictionary(); var listeners:Vector.