Reputation: 455
The situation is this:
1/ Class Grid.as
- Obtain the value of the option chosen // score:Number
- Generate a new instance: generateTrivia // trivia:generateTrivia
- Send the score value using a method // trivia.sendScore(score)
2/ Class generateTriva
- Save the score value score private function sendScore(rScore:Number){ this.pt = rScore; } - I created a variable to update the score after the question is answered // private var finalScore:Number = 0; - When the user clicks on send button:
a. Validate the answer
b. update the finalScore
// finalScore = finalScore + this.pt; - Finally I update the textfield to show the score Note: I've observed that the first time when the user answer the question correctly the accumulator: finalScore works fine but after that I don't know why does not add the new value of the variable (this.pt ) to the stored result UPDATED: I found something. After the answer is validated, the instance is removed and back to grilla, then repeat the process by question. I should store the result of the validation and send it back to the grid class and then process accumulate the value
Upvotes: 0
Views: 409
Reputation: 1768
You should learn how to debug a program. An error can be something started from uninitialized variable to "1 " (see the space there) converted to NaN.
The simplest way is to add trace()
statements in the functions where your score
and pu
values change. Better way is to set a breakpoint when user selects an option to answer and step through the execution monitoring variables.
Upvotes: 1