View Full Version : [AS3] score not appearing

09-09-2009, 07:00 PM
Hi there,
I'm making a gaming that has potentail points counting down and when you get the answer right it adds it to your score. For some reason it's not coming up with a total and just staying at 0.

Here is the code for the points system...

public function showGameScore() {
if (questionPoints != 0) {
scoreField.text = "Potential Points: "+questionPoints+"\t Your Score: "+gameScore;
} else {
scoreField.text = "Potential Points: ---\t Your Score: "+gameScore;
// start question points at max
questionPoints = 1000;


Later followed by....

// update the clock
public function updateClock(event:TimerEvent) {
questionPoints -= 25;
if (event.target.currentCount == event.target.repeatCount) {
messageField = createText("Out of time! The correct answer was:",questionFormat,gameSprite,0,90,550);


Here is the clock it runs by....

clock = new Clock();
clock.x = 50;
clock.y = 120.5;
questionTimer = new Timer(1000,20);
questionTimer.addEventListener(TimerEvent.TIMER,up dateClock);

09-09-2009, 07:13 PM
In the first code snippet you need to move the following lines out of the instance method.

questionPoints = 1000;

The reason why it's returning 0 is because questionPoints has no value. What you need to do is create either a local variableor an instance variable for questionPoints.

And as for calling the showGameScore() method from within itself I don't really know what to say about that except for are you wanting to call it over and over again? If so, why not just create a for loop?

09-09-2009, 08:51 PM
Many thanks for replying to me. I have included
private var questionPoints:int; to the class at the top but that hasn't made a difference.

I know I'm missing something dead obvious...I'm still a noob at all this....help:eek: