# Defining area for mouse\_out/over events which contain buttons

**URL:** <https://forum.kirupa.com/t/defining-area-for-mouse-out-over-events-which-contain-buttons/274322>\
**Category:** Uncategorized\
**Created:** [October 28, 2008, 2:24pm UTC](https://forum.kirupa.com/t/defining-area-for-mouse-out-over-events-which-contain-buttons/274322 "2008-10-28T14:24:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brookisme](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@brookisme](https://forum.kirupa.com/u/brookisme)\
**Post date:** [October 28, 2008, 2:24pm UTC](https://forum.kirupa.com/t/defining-area-for-mouse-out-over-events-which-contain-buttons/274322/1 "2008-10-28T14:24:39Z")

</div>

Hello All - This should have a really simple answer but I can´t get it to work out:

I want to define an area that when i leave triggers a mouse\_out event. however, within this area i want to have a button that does something when clicked. the catch is when i roll over the button i do NOT want the mouse\_out event to be triggered.

here is some overly simplified code to make the problem clear:

```auto

// draw container
var container:Sprite = new Sprite();
container.addEventListener(MouseEvent.MOUSE_OUT,cout);
container.addEventListener(MouseEvent.MOUSE_OVER,cover);
container.graphics.beginFill(0);
container.graphics.drawRect(0,0,100,100);
container.graphics.endFill()
container.graphics.beginFill(0);
container.graphics.drawRect(50,50,100,100);
container.graphics.endFill()

// draw button
var button:Sprite = new Sprite();
button.graphics.beginFill(0xffffff)
button.graphics.drawRect(100, 100, 30,30)
button.addEventListener(MouseEvent.CLICK,bclick);

// add sprites to stage
container.addChild(button)
addChild(container)

// listeners
function cover(e:MouseEvent):void {
	trace("over container");
}
function cout(e:MouseEvent):void {
	trace("you have left the container");
}
function bclick(e:MouseEvent):void {
	trace("button clicked");
}

```
