I’m an AS3 rookie with a capital R, so his may insult the intelligence of most here. I’m adding a quiz to my language website that tracks a score. It works except for one small thing; clicking the button continues to ‘up’ the score. What I need to have happen is when it enters ‘true’ mode, everything stops and the quizee can move on: Here’s the code and the rough draft of interface.
Button1.addEventListener(FocusEvent.FOCUS_IN,textInputHandler);
Button1.addEventListener(FocusEvent.FOCUS_OUT,textInputHandlerOut);
Button1.addEventListener(MouseEvent.CLICK, scoreUp);
Button1.addEventListener(MouseEvent.CLICK, scoreUpOut);
var ary:Array = [“Correct! Go to the next question.”, “Sorry, try again.”, “Incorrect. Move to the next question.”];
var Score:int = 0;
function textInputHandler(event:FocusEvent):void {
stage.addEventListener( MouseEvent.CLICK, keyDownHandler);
}
function textInputHandlerOut(event:FocusEvent):void {
//our textfield lost focus, remove our listener.
stage.removeEventListener( MouseEvent.CLICK, keyDownHandler);
}
function scoreUpOut(event:MouseEvent):void {
stage.removeEventListener(MouseEvent.CLICK, scoreUp);
}
function scoreUp(event:MouseEvent):void {
if (tf_input.text ==“True”) {
Score +=1
tf_counter.text = “Score:”+Score
} else if (tf_input.text == “true”) {
Score +=1
tf_counter.text = “Score:”+Score
} else {
Score +=0
tf_counter.text = “Score:”+Score
}
}
function keyDownHandler( me:MouseEvent ):void {
if (tf_input.text == “True”) {
setContent (ary[0]);
} else if (tf_input.text == “true”) {
setContent (ary[0]);
} else {
setContent (ary[1]);
}
}
function setContent (response:String):void {
tf_output.text = response;
}
thanks in advance for input
Marco Rank