next page -
1 -
2 -
3 -
4
- 5 -
6 -
7 -
8 -
9 -
Start the Quiz game
Now we can start coding the quiz-game. first thing: lets put this code in the first frame of our quiz_main.fla
import com.quiz.*;
init()
function init()
{
Quiz.main(this);
}
this import needs to give the path where there are our classes to avoid to
write all the path. it's only a shortcut.In fact you could use
com.quiz.Quiz.main(this);
instead of
Quiz.main(this);
and avoid to do the import. but we are lazy and we don't want to write every time
all the path
Inside the function init() we call
the static main function in the Quiz Class, that will create the application.
we are passing just the reference for the _root
So lets go in the Quiz class to create this main static function
static function main(root:MovieClip):Void
{
root = mc;
var app = root.attachMovie( "Quiz", "app_mc", 10 );
}
and add a setup function to the Quiz constructor. so the class will be:
import com.quiz.*;
class com.quiz.Quiz extends Quiz_base
{
static var root:MovieClip
public function Quiz()
{
setup()
}
private function setup()
{
trace("quiz esiste e vegeta")
}
static function main(mc:MovieClip):Void
{
root = mc;
var app = root.attachMovie( "Quiz", "app_mc", 10 );
}
}
At this point lets istance the quiz_intro, that will load the xml, create the start animation and at the end of this procedure, will call again the quiz class.
so write inside the function setup this code:
createChild("Quiz_intro","quiz_intro_mc",10)
and we set this method on the Quiz_base class because it will be a common tool for all the classes. so let's write this method in quiz_base
private function createChild(linkage:String,name:String,depth:Number)
{
return this.attachMovie(linkage,name,depth)
}
So let's open the Quiz_intro.as file
next page -
1 -
2 -
3 -
4
- 5 -
6 -
7 -
8 -
9 -