# Multiple buttons with AS3

**URL:** <https://forum.kirupa.com/t/multiple-buttons-with-as3/311620>\
**Category:** flash\
**Created:** [July 12, 2010, 5:45pm UTC](https://forum.kirupa.com/t/multiple-buttons-with-as3/311620 "2010-07-12T17:45:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lanawylma](https://avatars.discourse-cdn.com/v4/letter/l/58f4c7/32.png) [@lanawylma](https://forum.kirupa.com/u/lanawylma)\
**Post date:** [July 12, 2010, 5:45pm UTC](https://forum.kirupa.com/t/multiple-buttons-with-as3/311620/1 "2010-07-12T17:45:20Z")

</div>

Hi,

Please help… I’m working on a slide show which I would like work automatically (fade in and out) as well as being able to be prompted to switch via buttons… I know this is a super simple thing, but I cannot get all the buttons to work. The buttons are copies of the same instance with different instance names and are located at the 3 respective frames in timeline where the pieces of slideshow should fade in/out ( I hope this makes sense) I get the first set of buttons to work:

import flash.events.MouseEvent;

controls.bttn1.addEventListener (MouseEvent.CLICK, clickSection1);  
function clickSection1 (evtObj:MouseEvent) {  
// trace shows what’s happening in the output window  
trace (“The Button 1 was clicked!”)  
gotoAndPlay(“bttn1”);  
}

controls.bttn2.addEventListener (MouseEvent.CLICK, clickSection2);  
function clickSection2 (evtObj:MouseEvent) {  
// trace shows what’s happening in the output window  
trace (“The Button 2 was clicked!”)  
gotoAndPlay(“bttn2”);  
}

controls.bttn3.addEventListener (MouseEvent.CLICK, clickSection3);  
function clickSection3 (evtObj:MouseEvent) {  
// trace shows what’s happening in the output window  
trace (“The Button 3 was clicked!”)  
gotoAndPlay(“bttn3”);  
}

but when I add more buttons that are located later on in a timeline, I get the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at INDEX\_TEST\_r3\_fla::MainTimeline/frame1()

I hope this makes sense - I’d REALLY appreciate any help

Thank you!
