zoukankan      html  css  js  c++  java
  • 计时器

    /**************11111************************/

    private timeName: number;
    private isCanClick: boolean;
    private timeNum: number = 10;

    private clickFun(): void {
    let s = this;
    if (s.isCanClick) {
    s.isCanClick = false;

    s.timeName = loopMgr.setInterval(s.timeFun, s, 1000);
    }
    }

    private timeFun(): void {
    let s = this;

    if (s.timeNum <= 0) {
    s.clearTime();
    return;
    }
    s.timeNum--;

    }

    private clearTime(): void {
    let s = this;

    s.timeNum = 10;
    loopMgr.clearInterval(s.timeName);
    s.isCanClick = true;
    }

    /**************222************************/

    private timeIdx: number;

    private times: number = 10000;

    private isCanClick: boolean;

    private checkStatus(): boolean {
    let s = this;
    return s.isCanClick;
    }

    private clearTime(): void {
    let s = this;
    if (s.timeIdx)
    loopMgr.clearTimeOut(s.timeIdx);
    s.timeIdx = null;
    }

    private timeFun(): void {
    let s = this;
    s.isCanClick = false;
    s.timeIdx = loopMgr.setTimeOut(s.setStatus, s, s.times);
    }

    private setStatus(): void {
    let s = this;
    s.isCanClick = true;
    s.clearTime();
    }

    /**************333************************/

    private timeIdx: number;

    private times: number = 10;

    private isCanClick: boolean;

    private checkStatus(): boolean {
    let s = this;
    return s.isCanClick;
    }

    private clearTime(): void {
    let s = this;
    if (s.timeIdx)
    s.timeIdx = null;
    loopMgr.clearInterval(s.timeIdx);
    }

    private timeFun(): void {
    let s = this;
    s.isCanClick = false;
    s.timeIdx = loopMgr.setInterval(s.setStatus, s, 1000);
    /**执行的方法 */
    }

    private setStatus(): void {
    let s = this;
    if (s.times <= 0) {
    s.clearTime();
    s.isCanClick = true;
    s.times = 10;
    return;
    } else {
    s.times--;
    }
    }

  • 相关阅读:
    UltraSoft
    UltraSoft
    UltraSoft
    UltraSoft
    UltraSoft
    2020软工提问回顾与个人总结作业
    2020软工结对项目作业-简单几何形状间交点统计
    2020软工个人博客作业-博客园班级博客分析
    2020软工个人阅读博客作业
    2020软工第一次作业-热身
  • 原文地址:https://www.cnblogs.com/youziwulala/p/11550472.html
Copyright © 2011-2022 走看看