Search code examples
actionscript-3event-delegation

Does ActionScript 3 have some sort of event delegation system?


I have a container with many images. Instead of adding a listener for click and other mouse events on each of the images, I would like to only listen for those events on the parent of the image.

Is that possible?


Solution

  • container.addEventListener(MouseEvent.CLICK, clickHandler);
    private function clickHandler(e:MouseEvent):void {
      trace(e.currentTarget); // references container
      trace(e.target); //references container's child or container itself depending on what has been clicked 
    }