Hey there -
I have a project that requires a multiple choice game. Sadly, I'm not able to store the content in XML, so I have to create arrays to hold the questions and answers. I've chosen to hold the content in a separate .as file, QuizContent.as.
I have a MultipleChoiceQuiz.as file as well, a class to handle the quiz functionality. I'm having trouble accessing the content from the class however.
Here's a snippet of the QuizContent.as file:
and what I want to do with the class:Code:var qArray:Array;//store questions var fArray:Array;//store feedback qArray[0] = "which are problems for the world's oceans?"//question qArray[0][0] = "overfishing"; qArray[0][1] = "pollution"; qArray[0][2] = "coastal development"; qArray[0][3] = "all of the above"; fArray[0] = "all of these are problems";//feedback
I'm just seeing if I can access the qArray from the class to pick a random group of questions from the available content.Code://============================================================================== class com.asdf.MultipleChoiceQuiz { //============================================================================== private var score:Number; //============================================================================== public function MultipleChoiceQuiz() { //============================================================================== this.score = 0; initQuiz();//initialize quiz question array } private function initQuiz(){ trace(qArray.length); } }
Here's how the content/classes are loaded in my main timeline:
And the issue is that the class can't access the quiz content arrays.Code:import com.asdf.*; #include "as/Landing.as" #include "as/QuizContent.as" var act:Activity = new Activity(); var quiz:MultipleChoiceQuiz = new MultipleChoiceQuiz();
Any help is much appreciated. BTW - this is AS2 (flash 8 target player)
Thanks!




Reply With Quote