# Error 1009: One button works and the other doesnt...help?

**URL:** https://forum.kirupa.com/t/error-1009-one-button-works-and-the-other-doesnt-help/291267
**Category:** flash
**Created:** [June 26, 2009, 11:33pm UTC](https://forum.kirupa.com/t/error-1009-one-button-works-and-the-other-doesnt-help/291267 "2009-06-26T23:33:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Vathian](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@Vathian](https://forum.kirupa.com/u/Vathian)
#### Post date: [June 26, 2009, 11:33pm UTC](https://forum.kirupa.com/t/error-1009-one-button-works-and-the-other-doesnt-help/291267/1 "2009-06-26T23:33:14Z")

</div>

Hi there! I am experiencing an issue in AS3 that doesn’t seem like it should be one at all…

In my document class I have the following snippet of code…

```auto

package
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class DocumentClass extends MovieClip
	{
		public var menuScreen:MenuScreen;
		public var aoxGame:AoxGame;
		public var manualScreen:ManualScreen;
		
		public function DocumentClass()
		{
			showMenuScreen();
		}
		
		public function showMenuScreen():void
		{
			menuScreen = new MenuScreen();
			menuScreen.x = 0;
			menuScreen.y = 0;
			addChild( menuScreen );	
			menuScreen.execute_btn.addEventListener(MouseEvent.CLICK, executeClick);
                        menuScreen.manual_btn.addEventListener(MouseEvent.CLICK, manualClick);
		}
		
		public function executeClick(e:MouseEvent):void
		{
			aoxGame = new AoxGame(stage);
			aoxGame.x = 0;
			aoxGame.y = 0;
			addChild(aoxGame);
			
			removeChild(menuScreen);
			menuScreen = null;
		}
		
		function manualClick(e:MouseEvent):void
		{
			manualScreen = new ManualScreen();
			manualScreen.x = 0;
			manualScreen.y = 0;
			addChild(manualScreen);
			
			removeChild(menuScreen);
			menuScreen = null;
		}
	}
}

```

Both ManualScreen and AoxGame are exported for actionscript and the instance names of execute\_btn and manual\_btn are on all three keyframes of their animations…yet only executeClick responds.

Every time I run my program I receive the following error (if “menuScreen.manual\_btn.addEventListener(MouseEvent.CLICK, manualClick);” isn’t commented out):

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at DocumentClass/showMenuScreen()  
at DocumentClass$iinit()

I also applied a trace statement of “Working?” within the MenuScreen class file and it shows up before the error does! (Even though I don’t click on anything…)

Any ideas?

Thanks in advance!
