0

私はAS2.0を使用していて、movieClipを一定時間停止し、別の制限で再生する.swfムービーを作成しようとしていました。これは私がこれまでに得たものです。ループなしで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

映画をハングアップさせない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

私はAS2.0プログラマーではありませんが、whileループ内に遅延を追加すると役立つ場合がありますので、試してみてください。

于 2012-07-24T21:12:11.003 に答える
0

このチュートリアルはあなたを助けるはずです、それはそれがどのように機能するかについての素晴らしい内訳を与えますhttp://www.quip.net/blog/2006/flash/how-to-loop-three-times

于 2012-07-24T21:16:36.357 に答える
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 に答える