【问题标题】:Stop flash animation after 30 seconds30 秒后停止 Flash 动画
【发布时间】:2014-12-24 17:22:22
【问题描述】:

我正在运行闪存倒计时是倒计时到指定日期的倒计时。我想在播放 30 秒后停止倒计时。我需要做什么?

counter.onEnterFrame = function(){
currentDate = new Date();
currentMillisecs = currentDate.getTime();
this.msecs = eventMillisecs - currentMillisecs;
if (this.msecs <= 0){
    // the event time has been reached!
    // play the next frame for the result of the countdown.     
    play();
    return;
}

【问题讨论】:

    标签: javascript flash animation


    【解决方案1】:

    您可以使用setInterval,或setTimeout,或使用getTimer() 跟踪经过的时间。

    这是后者的一个例子:

    var initalTime = getTimer();
    counter.onEnterFrame = function(){
        if(getTimer() - initialTime > 30000) //stop counting
    
        ....
    

    或设置超时:

    setTimeout(30000, cancelCountdown);
    
    function cnacelCountdown(){
         //stop your countdown
    }
    

    【讨论】:

      最近更新 更多