我正在尝试使用 4 个按钮进行多项选择答案的测验。在您选择一个答案后,它会播放一个简短的动画并带您进入下一个问题。我一直在时间线代码中完成这一切,但已经了解到,因为 AS3 更适合使用类文件的 OOP,所以我现在正在尝试。
我认为不是每个问题制作 1 帧,而是为所有问题制作 1 帧,并从数组中填充问题标题和答案按钮。我最初在“动作脚本”层中定义了数组,但现在我决定在名为 DocumentClass.as 的类文件中进行。到目前为止,我未完成的代码是:
package {
import flash.display.MovieClip;
public class DocumentClass extends MovieClip
{
//global definitions
private var milanquestions:Array = new Array();
private var milancorrectanswers:Array = new Array();
private var userscore:Number = 0;
private var currentquestion:Number = 0;
milanquestions[0] = "What is the primary type of Rescue used?";
milanquestions[1] = "Why is Remote Lower the preffered method to use?";
milanquestions[2] = "Which pieces of equipment are needed to complete a Rescue safely?";
milanquestions[3] = "Who conducts the Rescue?";
milanquestions[4] = "Once the casualty reaches the ground, what is it important to do first?";
milanquestions[5] = "What is used to keep the casualty clear of any obstruction?";
milancorrectanswers[0] = "Remote Lower";
milancorrectanswers[1] = "It can be done without another operative needing to climb down to the casualty";
milancorrectanswers[3] = "A Balfour Beatty operative trained in Tower Rescue";
milancorrectanswers[4] = "Place in the recovery position and administer first aid where possible";
milancorrectanswers[5] = "A holding out rope";
public function DocumentClass()
{
//a place for listeners
}
}
}
使用此代码,我在数组的每个条目上都收到以下错误:
P:\Interactive Animation test folder\DocumentClass.as, Line 13 1120: Access of undefined property milanquestions.
P:\Interactive Animation test folder\DocumentClass.as, Line 14 1120: Access of undefined property milanquestions.
等等
我希望用问题和正确答案填充数组,但我似乎无法绕过这些错误。有任何想法吗?或者关于更好地做我想做的事情的任何建议?