首先,我对Flash非常陌生,所以我很开心。我过去做过一些编码,有能力阅读和理解代码,但是从头开始写代码会引起一些问题。
基本上我要做的就是用4个按钮进行测验以获得多项选择答案。选择答案后,它会播放一个简短的动画并带您进入下一个问题。我正在使用时间线代码完成所有这些但是已经学习了,因为AS3更适合使用类文件的OOP,所以我现在正在尝试。
我认为而不是每个问题制作1帧我将为所有问题制作1帧并填充问题标题和数组中的答案按钮。我最初在“Action Script”层中定义了数组,但现在我决定在名为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.
等
我希望用问题和正确的答案填充数组,但我似乎无法解决这些错误。有任何想法吗?或者有关更好地做我想做的事情的任何建议?
答案 0 :(得分:0)
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;
public function DocumentClass()
{
//a place for listeners
initAnswerAndQuestions();
}
private function initAnswerAndQuestions():void {
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";
}
}