why o why, TypeError: Error #1009: Cannot access a property or method of a null object reference?
So I have this scoreboard script which is basically gives points for clicking on the correct button and subtract points if clicking on the wrong button. Make story short, the script, which run from actionscript.as file, works great as long it's on the first keyframe sequence. but when trying to run it on the next keyframe sequence it gives me this Error #1009: error message (full message bellow). Please look at my script bellow and tell me what's wrong.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-3()
at scoreMe2()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at scoreMe2/frame1()
My Script:
package {
import flash.display.MovieClip
import flash.events.MouseEvent;
public class scoreMe2 extends MovieClip {
public function scoreMe2() {
//Scoreboard starts here:
var score: uint;
function init(): void {
score = 100;
scorecounter.text = "SCORE:" + score.toString();
clip.buttonMode = true;
clip.addEventListener(MouseEvent.CLICK, on_press1);
gButton.buttonMode = true;
gButton.addEventListener(MouseEvent.CLICK, on_press2);
}
//Positive button adding points
function on_press1(event: MouseEvent): void {
updateScore();
}
function updateScore(): void {
gotoAndStop(2);
score += 100;
scorecounter.text = "SCORE:" + score.toString()
stop();
}
//Negative button subtracting points
function on_press2(event: MouseEvent): void {
score += -20;
scorecounter.text = "SCORE:" + score.toString();
}
init();
//Scoreboard ends here:
}
}
}
