0

現在、インスタンス名が「powerbar」の MovieClip があります。合計 6 つのフレームがあり、特定の基準に応じて、特定のフレームを表示したいと考えています。これが私のコードです:

            if(char.throwing) {
            var pressLength:Number = getTimer()-startPress;

            if(pressLength >= 400) {
                powerbar.gotoAndPlay(6);
                trace("more than 400 " +String(powerbar.currentFrame));
            }
            else if(pressLength >= 300) {
                powerbar.gotoAndPlay(5);
                trace("more than 300 " +String(powerbar.currentFrame));
            }
            else if(pressLength >= 200) {
                powerbar.gotoAndPlay(4);
                trace("more than 200 " +String(powerbar.currentFrame));
            }
            else if(pressLength >= 100) {
                powerbar.gotoAndPlay(3);
                trace("more than 100 " +String(powerbar.currentFrame));
            }
            else if(pressLength >= 50) {
                powerbar.gotoAndPlay(2);
                trace("more than 50 " +String(powerbar.currentFrame));
            }
            else if(pressLength >= 25) {
                powerbar.gotoAndPlay(1);
                trace("more than 25 " +String(powerbar.currentFrame));
            }
            else if(pressLength >= 0) {

                powerbar.gotoAndPlay(1);
            }

それは正常にコンパイルされ、実行時にエラーはありません。ここで必要なものに応じて if ステートメントが機能しているかどうかも確認し、正しいムービー クリップを参照していることを確認しました (ムービー クリップの x 位置をトレースし、正解でした)。トレース (power bar.currentFrame) でそのフレームに行くかどうかをトレースしたところ、アニメーションでは表示されませんが、そのフレームに進んだことを示しています。 私も gotoAndStop を試しましたが、それでもうまくいきませんでした...助けてください!

4

1 に答える 1

0
        var pressLength:Number = getTimer()-startPress;

        //enterFrame/or keypress  function here:)
        if(char.throwing) {
        throwing_function();
        }

        function throwing_function (){
        if(pressLength >= 25 && pressLength<=49) { // check both conditions
            powerbar.gotoAndStop(2);
            trace("more than 25 but less than 50")
            trace(pressLength.toString) // i think
        }
        else if(pressLength >= 50 && pressLenght<=74) {check both conditions are good
            powerbar.gotoAndStop(3);
            trace("more than 50 but less than 75 ")
       }
       }

       etc......

しかし、これにアプローチするより良い方法があります。私はあなたのテーマに固執すると思いました

問題がある条件を 1 つだけチェックすることで、アセットをロードするプログレス バーでずっと前にこの間違いを犯しました。

于 2013-04-29T16:16:54.493 に答える