Накопить балл в AS3 - PullRequest
       4

Накопить балл в AS3

0 голосов
/ 27 февраля 2012
The situation is this:


    1/ Class <strong>Grid.as</strong> <br />
    - Obtain the value of the option chosen // <strong>score:Number</strong> <br />
    - Generate a new instance: generateTrivia  // <strong>trivia:generateTrivia</strong> <br />
    - Send the score value using a method // <strong>trivia.sendScore(score)</strong> <br />

    2/ Class <strong>generateTriva</strong> <br />
     - 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  
     //  <strong>private var finalScore:Number = 0;</strong>

    - When the user clicks on send button: <br />
    a. Validate the answer <br /> 
    b. update the finalScore<br />
     //  <strong>finalScore = finalScore + this.pt;</strong>

    - 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


    <strong>UPDATED</strong>: 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


1 Ответ

1 голос
/ 27 февраля 2012

Вы должны научиться отлаживать программу.Ошибка может быть чем-то начатым из неинициализированной переменной в «1» (см. Место там), преобразованной в NaN.

Самый простой способ - добавить операторы trace() в функции, где ваши score и pu значения меняются.Лучше установить контрольную точку, когда пользователь выбирает вариант ответа и пошагового просмотра переменных мониторинга выполнения.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...