首先,我完全不熟悉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.
等
我想填充有問題和正確答案的陣列,但我似乎無法解決這些錯誤。有任何想法嗎?或者有關更好的方法來做我想做的事情的任何建議?
嘗試把數組賦值的一些功能,並調用該函數的構造器 – Pan
就像我說的,我一直在使用動作腳本和Flash不到一天的時間,我沒有被交易程序員。任何答案都必須少一些模糊和更具描述性。 – user2527557