0

我目前有一个实例名称为“powerbar”的影片剪辑。它总共有 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......

但是有更好的方法来解决这个问题,我想我会坚持你的主题

通过只检查一个条件你有问题,我很久以前在加载资产的进度条上犯了这个错误。

于 2013-04-29T16:16:54.493 回答