hagop
September 30th, 2009, 06:15 AM
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.
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(); } }
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:
supermarket_mc.myButton_btn .addEventListener(MouseEvent.CLICK, turn);
myButton_btn does not react to click events and I get an additional error
Error #1009: Cannot access a property or method of a null object reference.
I suspect that the MouseEvent.CLICK in the class definition overrides the MouseEvent.CLICK on the nested button.
Any help would be appreciated
Thanks
Hagop
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.
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(); } }
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:
supermarket_mc.myButton_btn .addEventListener(MouseEvent.CLICK, turn);
myButton_btn does not react to click events and I get an additional error
Error #1009: Cannot access a property or method of a null object reference.
I suspect that the MouseEvent.CLICK in the class definition overrides the MouseEvent.CLICK on the nested button.
Any help would be appreciated
Thanks
Hagop