Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 跟踪一系列简单的多项选择网络表单答案_Actionscript_Actionscript 2 - Fatal编程技术网

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