# Simple error but dunno what the problem is

**URL:** <https://forum.kirupa.com/t/simple-error-but-dunno-what-the-problem-is/296090>\
**Category:** Uncategorized\
**Created:** [September 9, 2009, 1:33pm UTC](https://forum.kirupa.com/t/simple-error-but-dunno-what-the-problem-is/296090 "2009-09-09T13:33:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phingko](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@phingko](https://forum.kirupa.com/u/phingko)\
**Post date:** [September 9, 2009, 1:33pm UTC](https://forum.kirupa.com/t/simple-error-but-dunno-what-the-problem-is/296090/1 "2009-09-09T13:33:04Z")

</div>

anyone!!help me!!  
this is driving me insane!!!

i got this error  
Cannot access a property or method of a null object reference.

whenever I clicked on my button

```auto
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at test_fla::MainTimeline/onClick()

```

I know it means that the onClick is not on the stage,but I do put my buttons all in the same frame with the actionscript

here is my full actionscript,simple switch case

```auto
stop();

play_btn.addEventListener(MouseEvent.CLICK, onClick);
instruction_btn.addEventListener(MouseEvent.CLICK, onClick);
option_btn.addEventListener(MouseEvent.CLICK, onClick);
score_btn.addEventListener(MouseEvent.CLICK, onClick);
quit_btn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(evt:MouseEvent):void {
    switch (evt.target) {
        case play_btn :
        trace("play");
            content_mc.gotoAndPlay("play");
            break;
        case instruction_btn :
            content_mc.gotoAndPlay("instruction");
            break;
        case option_btn :
            content_mc.gotoAndPlay("option");
            break;
        case score_btn :
            content_mc.gotoAndPlay("score");
            break;
        case quit_btn :
            fscommand("quit");
            break;
    }
}

```

the trace can works but not the link  
i’m desperate :’(
