开发者

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);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜