我是新来的,对AS3来说很新。所以这是我疯狂的问题:
为什么我收到此错误:TypeError:错误#1010:术语未定义且没有属性。 在MethodInfo-1()
我正在研究这个功能:
/* a universal function for all the movieclips */
function clickAndPlay(element):Function {
/* return the click event */
return function(e:Event):void {
/* stop the event from propagating */
e.stopPropagation();
/* get the labels from the clip */
var labels:Array = element.currentLabels;
var numFrm:Number = labels.length; /* count them */
/* if there are no labels for this clip, get the frame length instead */
if(numFrm == 0) {
/* get the number of frames */
numFrm = element.totalFrames;
trace(numFrm);
if(element.currentFrame < numFrm) {
element.nextFrame();
}else{
element.gotoAndStop(1);
}
}else{
/* get the current index of the labels array */
for(var i:Number = 0; i < numFrm; i++) {
if(labels[i].name == element.currentLabel) {
if(i < numFrm) {
/* get the next label's name */
var labelName:String = labels[(i+1)].name;
/* go to the next label */
trace(labelName);
element.gotoAndStop(labelName);
}else{
element.gotoAndStop(1);
}
}
}
}
};
}
我不知道该功能是指什么。我已经检查过以确保框架上的标签是准确的,确实如此。我确定它有些愚蠢,但任何帮助都会受到赞赏。提前谢谢。
肖恩
答案 0 :(得分:0)
我相信你需要:
if (i < (numFrm-1)) {
而不是
if (i < numFrm) {
否则下一行在尝试访问标签[(i + 1)]
时会导致错误编辑:
考虑i = numFrm-1的情况(即:循环的最后一次迭代):
标签[(i + 1)]。名称与标签[(numFrm-1 + 1)]。名称或标签[numFrm] .name
相同但是,标签的长度是numFrm(这是你获得numFrm值的地方)所以你试图访问一个不存在的标签元素 - 数组从零开始索引,而不是1;所以如果标签有6个项目,最后一个是标签[5],而不是标签[6]