Making a Quiz Game
Start by inserting an additional 2 layers, so you will be left with 3 layers.
Name the bottom layer title, the middle Q’s and A’s and the top layer Actions.
Select modify from the menu option located at the top of the screen, then select document and change the colour to black(I am using black for this example, you use what ever you want).
Insert a keyframe at frame 2 on every layer.
Right click on the first frame of the action layer and select actions, now on the first line type in:
stop();
score = 0;
Now right click on the second frame of the action layer and select actions, on the first line type in:
percent = score/1*100+%;
(IMPORTANT NOTE: THERE MUST BE QUOTATION MARKS AROUND THE PERCENT SYMBOL.
The only reason I have not added the quotation marks is because this is a html document, and if I place the quotation marks around the % you will only see “”.
This is telling flash that the percent = whatever the score is(for this example I only have 1 question, so the score will be 1) divided by 100.(which is 100%). The +% means to add a % symbol at the end of the result.
On the first frame of the title layer, draw out a text box(static text) and type in the name of the quiz. For this example I will be using learnflash8pro.blogspot.com.
Now on the second frame of the title layer, draw out another text box(static text) and type in You Scored.
On the first frame of the Q’s and A’s layer, write out the question and the answers.
My question was Is learnflash8pro.blogspot.com the best site ever?
My answers were Yes and No.
I recommend that you place each of these underneath each other.
Eg. Is learnflash8pro.blogspot.com the best site ever?
Yes
No
Convert the answers in to 2 separate buttons. Right click on the correct answer and select action(of course the correct answer for me would be yes).
Add these actions to the correct answers:
on (release){
gotoAndStop(2);
score+=1;
}
This means that when the mouse is released the score will go up by one and go to the next frame.
Add these actions to the incorrect answer:
on (release){
gotoAndStop(2);
}
This means that when the mouse is released go to frame two. As this is the wrong answer we don’t want the score to go up.
Now on the 2nd keyframe of the Q’s and A’s layer, using the text tool(static text) draw out 3 text boxes, each underneath each other.
In the top text box type in: # of Questions:1
In the middle text box type in: # of Correct Questions:
Now in the bottom text box type in: Percentage:
Now using the text tool again, this time dynamic text, draw out a text box next to the # of Correct Questions text box, give it a var name of score.
Now using the text tool(still dynamic text) draw out a text box next to Percentage, and give this text box a var name of percent.
Congratulations, you have made your first quiz.
Now that you have the idea, create a quiz with a few questions, and obviously you will have to make minor changes to the Actionscript.
No comments:
Post a Comment