Actionscript 跟踪一系列简单的多项选择网络表单答案
这是我试图使用的代码,它似乎是合乎逻辑的。但似乎不起作用Actionscript 跟踪一系列简单的多项选择网络表单答案,actionscript,actionscript-2,Actionscript,Actionscript 2,这是我试图使用的代码,它似乎是合乎逻辑的。但似乎不起作用 MyAsFileName.prototype.getTotalScore = function() { var totalScore = 0; for (var i = 0; i < allQuestions.length; i++) { totalScore += allQuestions[i].getCalculatedScore(); if (currentModule.allQuestions[i].parent
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;
}
我的知识点定义为:
this.knowledgePoints = 10;
this.questionCorrect = false;
我的questionCorrect
定义如下:
this.knowledgePoints = 10;
this.questionCorrect = false;
第二次新尝试按照下面建议的答案使用新类(在我找到工作方法之前暂时不予评论):
//包
// {
/*公开课测验{
//公开的
var知识点:int=10;
//公开的
var allQuestions:Array=新数组;
//公开的
var-questionCorrect:Boolean=false;
//公开的
函数getTotalScore():int{
var totalScore:int=0;
对于(var i=0;i
上述代码在flash控制台中输出两个错误:
错误1。在类外使用的属性。
错误2。”无法加载Int。这是一种奇怪的(实际上是非AS3方式)方法。不要创建一个引用未知位置的奇怪变量的未命名闭包,您应该将其设置为一个普通的AS3类,类似这样的(在一个名为quick.as的文件中):
包
{
公开课测验
{
公共var知识点:int=10;
public var allQuestions:数组=新数组;
public var questionCorrect:Boolean=false;
公共函数getTotalScore():int
{
var totalScore:int=0;
//您的代码没有解释如何使用该数组。
//它最初是长度为0的空数组。
对于(var i=0;i
谢谢!我将尝试这种方法。您的注释是什么“//您的代码没有解释如何创建该数组。”?使用“调试日志”,我试图打印当前total@X-光线规格你的一些代码可能对你有意义,因为你知道全局。所以我发表评论来说明这一点。啊,好的。我发现2个错误:/1行为“公共类测验”-状态为“类外使用的属性”和“无法加载类或接口“int”。@X-RaySpecs,这意味着您使用的是AS1/2,而不是AS3。
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;
// Your code does not explain how you will that Array.
// It is initially an empty Array of length 0.
for (var i = 0; i < allQuestions.length; i++)
{
totalScore += allQuestions[i].getCalculatedScore();
if (currentModule.allQuestions[i].parent.questionCorrect)
{
knowledgePoints++;
}
else
{
knowledgePoints--;
}
}
// Not sure what it is.
debugLog("Total score: " + totalScore);
debugLog(knowledgePoints);
return totalScore;
}
}
}