听起来像Timer会完全符合您的要求。
设置一个全局计时器变量,其间隔取决于您希望评分系统有多精确,并在每个新问题时启动它。当用户回答时,检查该repeatCount
计时器的时间,看看他们需要多长时间才能正确回答。
public class Quiz{
private var mTimer:Timer;
...
public function Quiz():void{
// This creates a timer that will fire every 100 ms for 50 times.
// If you want a more precise scoring system, reduce the delay, and increase the count
mTimer = new Timer(100, 50);
}
private function newQuestion():void{
// Don't forget to reset the timer for every new question
mTimer.reset();
mTimer.start();
}
private function onRightAnswer():void{
// Check how many times the timer fired already
var count:int = mTimer.currentCount;
// Deduce points for every count
var score:int = 500 - (count * 10);
}
...
}