Home > front end >  Why I can't stop outside a function? clearInterval
Why I can't stop outside a function? clearInterval

Time:04-01

Private countDownTimer=0;
Private timeControl (second) {
If (second & gt; 0 {
This. CountDownTimer=egret. SetTimeout ()=& gt; {

}, this, 1000);

Enclosing countDownTimer=egret. SetInterval (function () {
If (second & gt; 0 & amp; & Enclosing bCanSelectFreeGame) {
Second,;
//the console log (' secound: 'second);
Let the STR: string=Utils. ReplaceString (Config. Language [' freeGameCountDown_ + Config. Lang], [second]);
MainGameView. Instance. ChangeGameTip (STR);

If (second & lt;=0) {
//the console. The log (" timing ");
ClearInterval (enclosing countDownTimer);//stop the end of the countdown effective

Let the STR: string=Utils. ReplaceString (Config. Language [' mainGame016_ + Config. Lang]);
MainGameView. Instance. ChangeGameTip (STR);
}
}
}, this, 1000);
}
}



Private onOpenButton (evt: egret. Event) {
Let the self=this;

ClearInterval (enclosing countDownTimer);//at the end of the countdown has not click the stop button is invalid?
}

CodePudding user response:

This. CountDownTimer=egret. SetTimeout ()=& gt; {

}, this, 1000);
This sentence don't, intending to change the wording
  • Related