I’m writing a bingo/quiz game in Flash CS6 / Actionscript 2.0 (AS3 kicked my *** and I’m on a deadline =X) that needs to call randomly from a long list of questions (about 240). What I’m trying to do is create a Question class with some properties, create a bunch of objects in the Question class, and then call those objects. Trouble is, I’m not sure how to do that in Flash’s strict “class.as” packaging.
Here’s the code as it worked in Javascript:
function Question(question, rightAnswer, answer2, answer3) { this.question = question, this.rightAnswer = rightAnswer, this.answer2 = answer2, this.answer3 = answer3 } var testQuestion1 = new Question( "What's the right answer?", "This one", "Not this one", "Or this one") var questionList = [testQuestion1]
And then I can shuffle up questionList and get my question with questionList.pop().
But in Flash, I’m not sure where to put that code or how to access it. I tried making a Question.as, but it told me I wasn’t allowed to make new objects inside the class description, and in any case I wasn’t sure how to call it. I considered making an invisible question box and attaching code to it (
class Question extends MovieClip
), but then I still don’t know how to define new questions inside it. I suppose if I get desperate, I can use an enemy spawning algorithm to spawn 240 question boxes . . .
Basically, I want to make a class for objects that don’t physically exist in the gameworld, and create about 240 objects in that class, then stick them into an array so I can call them.
Thanks in advance for your help.