# Buttons inside mc affecting the code

**URL:** <https://forum.kirupa.com/t/buttons-inside-mc-affecting-the-code/298950>\
**Category:** Uncategorized\
**Created:** [October 27, 2009, 4:30pm UTC](https://forum.kirupa.com/t/buttons-inside-mc-affecting-the-code/298950 "2009-10-27T16:30:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CayoHueso](https://avatars.discourse-cdn.com/v4/letter/c/8e8cbc/32.png) [@CayoHueso](https://forum.kirupa.com/u/CayoHueso)\
**Post date:** [October 27, 2009, 4:30pm UTC](https://forum.kirupa.com/t/buttons-inside-mc-affecting-the-code/298950/1 "2009-10-27T16:30:10Z")

</div>

Hi,  
I have this code that makes a menu with two buttons appear following the mouse when the mouse rolls over a movieClip:

```auto

var imgOptions:menuMC = new menuMC();
//Makes the image options follow the mouse
function showImgOptions (e:Event):void
{
    imgOptions.mouseEnabled = false;
    //If the imgOptions is touching the mouseX/mouseY coord
    if (imgOptions.hitTestPoint(mouseX,mouseY,false))
    {
        imgOptions.y = imgOptions.y;
        imgOptions.x = imgOptions.x;
    }
    else
    {
        //Make yje imgOptions follow the mouse with some delay
        var delayX:int = imgOptions.x - mouseX;
        var delayY:int = imgOptions.y - mouseY;
        imgOptions.x -= delayX / 5;
        imgOptions.y -= delayY/5;
    }
}

//EventListeners for the imgOptions
imgOptions.close_btn.addEventListener (MouseEvent.CLICK, closeClick, false, 0, true);
imgOptions.zoom_btn.addEventListener (MouseEvent.CLICK, zoomClick, false, 0, true);

//Close image
function closeClick (e:MouseEvent):void
{
    trace ("close");
}
//Opens a bigger version of the image
function zoomClick (e:MouseEvent):void
{
    trace ("zoom");
}
img_mc.addEventListener (MouseEvent.MOUSE_OVER,onBigOver);
img_mc.addEventListener (MouseEvent.MOUSE_OUT,onBigOut);

function onBigOver (e:MouseEvent):void
{
    stage.addEventListener (Event.ENTER_FRAME, showImgOptions);
    imgOptions.x=mouseX;
    imgOptions.y=mouseY;
    addChild (imgOptions);

}

function onBigOut (e:MouseEvent):void
{
    removeChild (imgOptions);
}

```

The problem is that the buttons are children of imgOptions, and when the mouse is over these two buttons, the movie reacts like the mouse is not over the imgOptions movieclip.

Could you please share some advice?  
Thanks
