# Help a Rookie kill a function

**URL:** <https://forum.kirupa.com/t/help-a-rookie-kill-a-function/316300>\
**Category:** flash\
**Created:** [November 18, 2010, 1:46am UTC](https://forum.kirupa.com/t/help-a-rookie-kill-a-function/316300 "2010-11-18T01:46:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_rank](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@Marco\_rank](https://forum.kirupa.com/u/Marco_rank)\
**Post date:** [November 18, 2010, 1:46am UTC](https://forum.kirupa.com/t/help-a-rookie-kill-a-function/316300/1 "2010-11-18T01:46:56Z")

</div>

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.  
 ![](http://www.spectraenglish.com/php3dp30mub0020/images/test_screencap.png)  
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
