【问题标题】:what does this do var index_num:Number= 1; var numFrames:int = this.dances_mc.totalFrames; ( AS3)这是做什么的 var index_num:Number= 1; var numFrames:int = this.dances_mc.totalFrames; (AS3)
【发布时间】:2012-08-17 02:39:35
【问题描述】:

我有一点问题...我正在尝试为我的朋友们为大学做 flash 项目。这实际上很容易,但我基本上不了解 AS3,因为我不再使用 flash 代替全职几年前的编码。无论如何,它必须在明天早上,所以如果有人为我破解这段代码,我(和我可怜的朋友)将永远感激不尽..

这条线是做什么的:

var numFrames:int = this.dances_mc.totalFrames;

时间轴的第一帧有一个叫dances_mc的符号,里面有5帧左右,还有一个stop函数。这些框架中的每一个都包含不同的文本和图像。有一个完整的演示,其中按钮会导致文本和图像发生变化,并在最后循环。

文件中的AS如下所示:

trace("movie starts"+this.dances_mc.totalFrames);

var index_num:Number= 1;
var numFrames:int = this.dances_mc.totalFrames;

// Your code goes here

stop();

我需要编写一个事件处理程序,每次按下按钮时显示下一个舞蹈。然后改进Event Handler,一旦显示最后一支舞,按下按钮就会再次显示第一支舞。

提前致谢!!

【问题讨论】:

    标签: actionscript-3


    【解决方案1】:

    有问题的行告诉您该影片剪辑中有多少帧,因此您可以知道何时循环回到第一帧。

    代替你的//你的代码在这里:

    function nextDance(e:MouseEvent = null):void {
        index_num++;  //increment your current index when the button is clicked
        if(index_num > numFrames){  //if your index is higher than the total amount of frame, go back to the first one
            index_num = 1;
        }
        this.dances_mc.gotoAndStop(index_num); //go to the frame of the new current index;
    }
    
    yourButton.addEventListener(MouseEvent.CLICK,nextDance,false,0,true);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-30
      • 2014-08-31
      相关资源
      最近更新 更多