0

我正在使用 AS2.0 并试图制作一部 .swf 电影,该电影在一段时间内停止 movieClip 并在另一个限制内播放。这就是我到目前为止所得到的,它可以在没有循环和 if 条件的情况下工作,但我需要有一个循环,这样它才能按我的意愿工作。请帮助我,谢谢。

myDate = new Date();
hrs = myDate.getHours();

while ( hrs >6 && hrs <21)  // time range i want the movieclip to stop
{
stop();     // to stop the timeline
Night.stop();   // " Night " is the instance name of the movieclip
hrs = myDate.getHours();    // to update the time 
}

stop();     // to stop the timeline
Night.play();   // it's out of the time limit so the movieclip should play
4

4 回答 4

0

我不是 AS2.0 程序员,但也许在 while 循环中添加延迟可能会有所帮助,试一试。

于 2012-07-24T21:12:11.003 回答
0

This tutorial should help you out, it gives a great breakdown of how it works as well http://www.quip.net/blog/2006/flash/how-to-loop-three-times

于 2012-07-24T21:16:36.357 回答
0

您可以利用不会挂起电影的 onEnterFrame 事件

this.onEnterFrame = function() {
    var myDate = new Date();
    var hrs = myDate.getHours();

    while ( hrs >6 && hrs <21)  // time range i want the movieclip to stop
    {
    stop();     // to stop the timeline
    Night.stop();   // " Night " is the instance name of the movieclip
    hrs = myDate.getHours();    // to update the time 
    }

    stop();     // to stop the timeline
    Night.play();
}
于 2012-07-24T21:20:01.223 回答
0

在 flash + actionscript 中,您可能希望利用时间线、间隔或输入帧处理程序而不是循环来发挥自己的优势。该循环旨在执行重复(或类似)代码,直到条件为真。

当在时间轴或符号上的一帧内使用循环时,它不允许下一帧绘制和刷新 - 这实际上会使播放器超时(您是否在 Flash 中收到 15 秒超时错误?)并且一切都“冻结” 。”

“进入框架”的方式是(这不是我的想法):

onEnterFrame = function(){ // execute the following on every frame
    hrs = (new Date()).getHours(); // get the current hour 
    if ( hrs >6 && hrs <21) { // time range i want the movieclip to stop
        Night.gotoAndStop(1); // stop and reset Night
        Night.alpha = 0; // hide Night
    } else {
        /*
            if Night's frame is "1" then we can assume that Night is not playing,
            however, in the event it is playing already, it will just keep playing
            without missing a beat
        */
        if ( Night.currentFrame == 1 ) {
            Night.alpha = 1; // show Night
            Night.gotoAndPlay(2); // advance to the next frame
        }
    }
}

stop(); // stop the main timeline
Night.play(); // play Night by default
于 2012-07-24T21:24:26.853 回答