【问题标题】:MovieClip not showing the right frame影片剪辑未显示正确的帧
【发布时间】:2013-04-22 09:33:46
【问题描述】:

我目前有一个实例名称为“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,但还是不行……请帮忙!

【问题讨论】:

  • gotoAndStop 而不是 gotoAndPlay ?
  • 我一开始试过了还是不行,现在改了还是不行
  • 您的错误不在该代码范围内。这意味着您可能做了其他错误的事情。您很可能误解了动画在 Flash 中的工作方式。或者当你开始你的动画时你认为会发生什么。或者powerbar 没有链接到正确的movieclip,或者presslength 没有在调用之间重置或者完全不同的东西是错误的。我想说的是,该代码没有任何问题,因此没有人能够根据您的解释帮助您实现您想要的。
  • 如果 pressLength 是负数会怎样?你没有处理这种情况。跟踪 startPress 和 pressLength 以确定。此外,正如 Lee Burrows 所指出的,gotoAndStop() 具有您想要的行为。
  • 尝试在每一帧上插入关键帧来打断补间。

标签: actionscript-3 flash flash-cs6


【解决方案1】:
        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......

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-07
    • 2012-05-24
    • 1970-01-01
    • 2020-10-28
    • 1970-01-01
    • 2011-01-31
    • 1970-01-01
    相关资源
    最近更新 更多