;

PDA

Click to See Complete Forum and Search --> : Problem with my buttons, please help


icydevil17
04-27-2008, 09:44 AM
OK, I really need help here. I am creating a flash file with 6 steps of instruction with buttons such as "next" and "previous" in it to move along the steps. After designing my layout and doing my actionscript3, I click "test movie". and then i receive the error #1009: cannot access a property or method of a null object reference. But the thing is that, I am able to click the first button on my screen and move to the next step, after that my button don't work anymore. Hope you guys would understand this.

Here are my actionscript:

stop();
startBtn.addEventListener(MouseEvent.CLICK, clickHandler1);
nextBtn1.addEventListener(MouseEvent.CLICK, clickHandler2);
previousBtn2.addEventListener(MouseEvent.CLICK, clickHandler3);
nextBtn2.addEventListener(MouseEvent.CLICK, clickHandler4);
previousBtn3.addEventListener(MouseEvent.CLICK, clickHandler5);
nextBtn3.addEventListener(MouseEvent.CLICK, clickHandler6);
previousBtn4.addEventListener(MouseEvent.CLICK, clickHandler7);
nextBtn4.addEventListener(MouseEvent.CLICK, clickHandler8);
previousBtn5.addEventListener(MouseEvent.CLICK, clickHandler9);
nextBtn5.addEventListener(MouseEvent.CLICK, clickHandler10);
previousBtn6.addEventListener(MouseEvent.CLICK, clickHandler11);

function clickHandler1(event:MouseEvent):void{
gotoAndStop(5);
}
function clickHandler2(event:MouseEvent):void{
gotoAndStop(12);
}
function clickHandler3(event:MouseEvent):void{
gotoAndStop(5);
}
function clickHandler4(event:MouseEvent):void{
gotoAndStop(19);
}
function clickHandler5(event:MouseEvent):void{
gotoAndStop(12);
}
function clickHandler6(event:MouseEvent):void{
gotoAndStop(25);
}
function clickHandler7(event:MouseEvent):void{
gotoAndStop(19);
}
function clickHandler8(event:MouseEvent):void{
gotoAndStop(31);
}
function clickHandler9(event:MouseEvent):void{
gotoAndStop(25);
}
function clickHandler10(event:MouseEvent):void{
gotoAndStop(37);
}
function clickHandler11(event:MouseEvent):void{
gotoAndStop(31);
}

Please help me and thanks a lot.

cancerinform
04-27-2008, 10:42 AM
Probably one or more of the buttons is not there and that is why you get null.

neznein9
04-27-2008, 11:55 AM
When that code is run only startBtn and nextBtn1 are on stage so as far as the code knows, the other's dont even exist...You need to make it so the other buttons are on stage at that time or else initilialize the later buttons as the become available.

icydevil17
04-28-2008, 10:00 PM
i don't really understand what you are trying to say, sorry about that, I am very new to Flash, can you kindly explain it in easier way? if possible.

cancerinform
04-29-2008, 06:27 AM
Are all your buttons listed in the script in the frame where this script is located?

icydevil17
04-29-2008, 08:09 AM
ohh rightt.. i understand now. finally it is working. Thanks a lot for the help!