我正在使用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
答案 0 :(得分:0)
我不是AS2.0程序员,但是在while循环中添加延迟可能有所帮助,试一试。
答案 1 :(得分:0)
本教程应该可以帮助您,它可以很好地分析它的工作原理http://www.quip.net/blog/2006/flash/how-to-loop-three-times
答案 2 :(得分: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();
}
答案 3 :(得分: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