Issues with stopping a timer via another function
Hello,
So I am creating a quiz buzzer system in Flash.
My issue comes here: In one round, a player is given an obstacle of a half second delay before the buzz-in function activates. This works fine; however, if another player buzzes in, the slowed down player is still going through their buzz-in function and it wrecks my system reset. Below is my code that I altered to try to get this to work with one player before I try for all three—with a longer delay than what would be the final timer.
Penalized player has the event listener for standard buzz in (p1buzzin) replaced with a listener for a different function (p1Messed) that starts a timer (fTimer) and then does its own separate buzz-in function (p1buzzb).
I have a feeling that I am going about this the wrong way, but not sure how to rectify this. Any help would be appreciated!
RELEVANT CODE:
var fTimer: Timer = new Timer(2000, 1);
- fTimer.addEventListener(TimerEvent.TIMER_COMPLETE, p1buzzb);
function p1Messed(event: KeyboardEvent): void {
if (buzzersActive == true && p1Buzz == false && event.keyCode == 37) {
fTimer.start();
}}
function p1buzzb(event: TimerEvent): void {
p1Buzz = true;
buzzersActive = false;
trace("Player 1");
addChild(leftbuzz);
ringin.play();
}
function checkTimer(): void {
if (fTimer.start == true) {
fTimer.stop();
}
}
function p1buzzin(event: KeyboardEvent): void {
if (buzzersActive == true && p1Buzz == false && event.keyCode == 37) {
p1Buzz = true;
buzzersActive = false;
trace("Player 1");
addChild(leftbuzz);
ringin.play();
}
}
function p2buzzin(event: KeyboardEvent): void {
if (buzzersActive == true && p2Buzz == false && event.keyCode == 38) {
p2Buzz = true;
buzzersActive = false;
trace("Player 2");
addChild(cenbuzz);
ringin.play();
checkTimer();
}
