Being a Java programmer you'll probably find it easier with a MVC system. Below is an example of how to build one in Flash.
Your model consists of a Questions class which contains many objects of type Question. You might build your Question object like:
class com.mysite.question.GenericQuestion{
private var id:String //this questions ID
private var text:String; //the question
private var answers:Array=new Array(); //a list of answers
private var sendLocations:Array = new Array(); //a list of which question id the corresponding answer sends you to
public function GenericQuestion(node:XMLNode)
/*
we're passing in an XML node because Flash handles XML well, and it sounds like your requirements can be met by it. Assign values of the node to this objects variables.
*/
}
public function getQuestion():String{
return question;
}
//make more getters
}
- class com.mysite.question.GenericQuestion{
- private var id:String //this questions ID
- private var text:String; //the question
- private var answers:Array=new Array(); //a list of answers
- private var sendLocations:Array = new Array(); //a list of which question id the corresponding answer sends you to
- public function GenericQuestion(node:XMLNode)
- /*
- we're passing in an XML node because Flash handles XML well, and it sounds like your requirements can be met by it. Assign values of the node to this objects variables.
- */
- }
-
- public function getQuestion():String{
- return question;
- }
- //make more getters
- }
The GenericQuestion and any other types of question classes can be held inside of a Questions class. The Questions class needs among other things a method where given a question id, it returns that question.
Then your xml might look like
<xml>
<questions>
<question id="start">
<text>What should I do now?</text>
<answers>
<answer sendLocation="He Ran">Run</answer>
<answer sendLocation="He Hid">Hide</answer>
<answer sendLocation="He Walked">Walk</answer>
</answers>
</question>
<question id="He Hid">
<text>Your hiding failed, you were found. What should you do now?</text>
<answers>
<answer sendLocation="He Ran">Run</answer>
<answer sendLocation="He Flew">Fly</answer>
<answer sendLocation="He Walked">Walk</answer>
</answers>
</question>
...
</questions>
- <xml>
- <questions>
- <question id="start">
- <text>What should I do now?</text>
- <answers>
- <answer sendLocation="He Ran">Run</answer>
- <answer sendLocation="He Hid">Hide</answer>
- <answer sendLocation="He Walked">Walk</answer>
- </answers>
- </question>
- <question id="He Hid">
- <text>Your hiding failed, you were found. What should you do now?</text>
- <answers>
- <answer sendLocation="He Ran">Run</answer>
- <answer sendLocation="He Flew">Fly</answer>
- <answer sendLocation="He Walked">Walk</answer>
- </answers>
- </question>
- ...
- </questions>
-
You can see how that XML can build your model.
You will have to draw a GUI which is the view. Then build a controller which handles user interaction and draws model data onto the view.
That is one good way to do it.