【发布时间】:2017-10-09 09:39:29
【问题描述】:
这是我正在尝试使用的代码,这似乎是合乎逻辑的。但似乎不起作用。
MyAsFileName.prototype.getTotalScore = function() {
var totalScore = 0;
for (var i = 0; i < allQuestions.length; i++) {
totalScore += allQuestions[i].getCalculatedScore();
if (currentModule.allQuestions[i].parent.questionCorrect == true) {
knowledgePoints++;
} else {
knowledgePoints--;
}
}
debugLog("Total score: " + totalScore);
debugLog(knowledgePoints);
return totalScore;
}
我将allQuestions 定义如下:
var allQuestions = Array();
我将knowledgePoints 定义为:
this.knowledgePoints = 10;
我将questionCorrect 定义为:
this.questionCorrect = false;
第二次新尝试使用新课程作为以下建议的答案(暂时注释掉,直到我弄清楚如何开始工作):
// package
// {
/*public class Quiz {
//public
var knowledgePoints: int = 10;
//public
var allQuestions: Array = new Array;
//public
var questionCorrect: Boolean = false;
//public
function getTotalScore(): int {
var totalScore: int = 0;
for (var i = 0; i < allQuestions.length; i++) {
totalScore += allQuestions[i].getCalculatedScore();
if (currentModule.allQuestions[i].parent.questionCorrect) {
knowledgePoints++;
} else {
knowledgePoints--;
}
}
debugLog("Total score: " + totalScore);
debugLog(knowledgePoints);
return totalScore;
}
}*/
//}
上面这段代码在 flash 控制台中输出两个错误:
错误 1. 属性在类外使用。
错误 2。无法加载“Int”。
【问题讨论】:
标签: actionscript actionscript-2