Flash looping causing variable value issues
Flash keeps looping which is causing certain variables to add values constantly. E.g.
if (userWord.text =开发者_如何学Go= word){
score = score + 1;
trace(score);
}
That will constantly add one to "score" when a certain word is typed into a text box.
How do I add one to "score" without stopping the application or playing it once?
Add an eventListener to your text field and have it react to Event.CHANGE:
userWord.addEventListener (Event.CHANGE, onWordChange);
function onWordChange (ev:Event) : void {
if (userWord.text == word) {
score = score + 1;
trace (score);
}
}
精彩评论