# Nested Button Problem

**URL:** <https://forum.kirupa.com/t/nested-button-problem/297327>\
**Category:** flash\
**Created:** [September 30, 2009, 10:15am UTC](https://forum.kirupa.com/t/nested-button-problem/297327 "2009-09-30T10:15:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hagop](https://avatars.discourse-cdn.com/v4/letter/h/97f17d/32.png) [@hagop](https://forum.kirupa.com/u/hagop)\
**Post date:** [September 30, 2009, 10:15am UTC](https://forum.kirupa.com/t/nested-button-problem/297327/1 "2009-09-30T10:15:39Z")

</div>

Hi all

I have created an invisible button **myButton\_btn** inside a moviclip with instance name **supermarket\_mc**. The **supermarket\_mc** is based on a class Supermarket, which has the following code and works fine.

[COLOR=red]public class Supermarket extends MovieClip  
{  
public function Supermarket()  
{ this.addEventListener(MouseEvent.MOUSE\_DOWN,go); }

private function go(event:MouseEvent):void  
{ this.play();  
this.addEventListener(MouseEvent.MOUSE\_UP,hop);  
}  
private function hop(event:MouseEvent):void  
{ this.stop(); } }[/COLOR]

Now, if I have a button on Stage they work fine when I add a listener to them. However, when I add a listener to **myButton\_btn** ie:  
[COLOR=red]supermarket\_mc.\*\*myButton\_btn \*\*.addEventListener(MouseEvent.CLICK, turn); [/COLOR]  
\*\*[COLOR=#ff0000][COLOR=black]myButton\_btn[/COLOR] [COLOR=black]does not react to click events[/COLOR] [/COLOR]\*\*and I get an additional error  
[COLOR=red]Error #1009: Cannot access a property or method of a null object reference.[/COLOR]  
[COLOR=#ff0000][/COLOR]  
[COLOR=black]I suspect that the MouseEvent.CLICK in the class definition overrides the MouseEvent.CLICK on the nested button. [/COLOR]  
[COLOR=black][/COLOR]  
[COLOR=black]Any help would be appreciated [/COLOR]

Thanks  
Hagop
