Actionscript 3 这对var index_num:Number=1有什么作用;var numFrames:int=this.dances\u mc.totalFrames;(AS3)

Actionscript 3 这对var index_num:Number=1有什么作用;var numFrames:int=this.dances\u mc.totalFrames;(AS3),actionscript-3,Actionscript 3,我有点问题。。。我正在为大学做我的朋友们的flash项目。。这其实很简单,但我基本上不了解AS3,因为几年前我停止使用flash代替全职编码。无论如何,它必须在明早,所以,如果有人打破了这个密码,我(和我可怜的朋友)将永远感激 这条线的作用是: var numFrames:int=this.dances\u mc.totalFrames 在时间线的第一个帧上有一个称为dances_mc的符号,其中有5个左右的帧和一个停止函数。每个框架都包含不同的文本和图像。有一个完整的演示,其中按钮会导致文本和

我有点问题。。。我正在为大学做我的朋友们的flash项目。。这其实很简单,但我基本上不了解AS3,因为几年前我停止使用flash代替全职编码。无论如何,它必须在明早,所以,如果有人打破了这个密码,我(和我可怜的朋友)将永远感激

这条线的作用是:

var numFrames:int=this.dances\u mc.totalFrames

在时间线的第一个帧上有一个称为dances_mc的符号,其中有5个左右的帧和一个停止函数。每个框架都包含不同的文本和图像。有一个完整的演示,其中按钮会导致文本和图像发生变化,并在最后循环

文件中的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();
我需要编写一个事件处理程序,在每次按下按钮时显示下一个舞蹈。然后改进事件处理程序,以便在显示最后一个舞蹈后,按下按钮将再次显示第一个舞蹈


提前谢谢

这一行告诉您该电影剪辑中有多少帧,这样您就可以知道何时循环回第一帧

代替//您的代码如下所示:

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);