# Adding a listener to a Child object

**URL:** <https://forum.kirupa.com/t/adding-a-listener-to-a-child-object/239024>\
**Category:** flash\
**Created:** [September 18, 2007, 4:38am UTC](https://forum.kirupa.com/t/adding-a-listener-to-a-child-object/239024 "2007-09-18T04:38:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zubin101](https://avatars.discourse-cdn.com/v4/letter/z/51bf81/32.png) [@zubin101](https://forum.kirupa.com/u/zubin101)\
**Post date:** [September 18, 2007, 4:38am UTC](https://forum.kirupa.com/t/adding-a-listener-to-a-child-object/239024/1 "2007-09-18T04:38:17Z")

</div>

I’ve created a container called “menu\_container” and a child object called “hitbox” within it. When I add AddEventListener to the hitbox, it doesn’t call the specified function at all. Here is the code:

```php

    // Create Container
    var menu_container:MovieClip = new MovieClip();
    addChild(menu_container);
 
    // Create hitBox
    var hitbox:Shape = new Shape();
    hitbox.name = "hitbox";
    hitbox.graphics.beginFill(0xFFFFFF);
    hitbox.graphics.drawRect(0, 0, 250, 100);
    hitbox.graphics.endFill();
    menu_container.addChild(hitbox);
 
    menu_container.getChildByName("hitbox").addEventListener(MouseEvent.MOUSE_OVER, moveIconMenu);
 
    function moveIconMenu(e:Event):void {
     trace("hello");
    }

```

Can anybody explain this? I’m completely stumped… Thanks for your time.
