I have a slideshow with 4 pictures and runs on a timer. I have a movie clip called play_mc. Inside the movie clip is a button with an instance name of play_btn on keyframe 1. Then on keyframe 2 there is another button with an instance name pause_btn. On the AS3 layer, I have this code:
stop();
play_btn.addEventListener(MouseEvent.CLICK, goToPause);
function goToPause(Event:MouseEvent){
gotoAndStop(2);
}
pause_btn.addEventListener(MouseEvent.CLICK, goToPlay);
function goToPlay(Event:MouseEvent){
gotoAndStop(1);
}
On the main stage on the as3 layer, I have this code (this is not all of the code - all other code works without the play_mc movie clip)
myTimer.addEventListener(TimerEvent.TIMER, autoAdvance);
function autoAdvance(event:TimerEvent){
if(imageNumber<totalImages){
imageNumber++;
}
else(imageNumber = 1);
reload();
}
function reload(){
removeChild(myLoader);
myRequest = new URLRequest(imageNumber + ".jpg");
myLoader.load(myRequest);
addChildAt(myLoader, 1);
}
play_mc.addEventListener(MouseEvent.MOUSE_DOWN, stopTimer);
function stopTimer(event:Event){
myTimer.stop();
}
play_mc.addEventListener(MouseEvent.MOUSE_DOWN, resumeTimer);
function resumeTimer(event:Event){
myTimer.start();
}
I get an error saying:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at gallery_fla::play_Mc_3/frame1()
Basically when I click on the Play button the slideshow starts and the text changes to "Pause" but when I click again, the slideshow does not pause and the text won't change back to "Play".
Anyone have an idea how to help me out here, please??