Editing a Quiz Component

Component 

Open the quiz.fla file in the Chapter 9 folder on the CD (see Figure 9.1). Save the file to your local computer so that you can save your edits as you follow along. Locate the file named quiz.txt and copy it to the same folder on your local computer that you saved the quiz.fla file.

click to expand
Figure 9.1: The open quiz.fla file

start sidebar

The components in this chapter are from www.gamesinaflash.com and are for educational purposes only. To use these games on your websites, you must license them from Eyeland Studio, Inc. (www.eyeland.com or www.gamesinaflash.com).

end sidebar

Go ahead and test the movie to see how the quiz game works. If you play the game, you will see that the quiz game works like standard quiz games. You are presented with a question in a white box, and you need to click on the button next to the correct answer, as shown in Figure 9.2. If you get the answer right, the game pauses for a few seconds and then moves on to the next question. If you get the answer wrong, the game pauses to show you the correct answer and then moves on to the next question after a few seconds.

click to expand
Figure 9.2: Test the Quiz game to observe how it functions with the current or default settings.

Close the test movie window after you've observed how the quiz game works with its current or default settings. Now let's look at the Quiz component and the options the component provides for customizing the game. Make sure that you are on frame 1 in the scene named Game, and then select the Quiz component and open the Component Parameters panel. Click the Next button to view the first page of parameters (Figure 9.3).

click to expand
Figure 9.3: The Component Parameters panel for the Quiz component

Here is a list describing the Quiz component parameters:

File Name The File Name parameter is where you specify the name of the text file that contains the quiz questions and answers (the parameter is not case-sensitive). The text file needs to be located in the same directory as the .swf file for the quiz game. The game uses the text and answers in the text file to generate the game.

Game Time The Game Time parameter specifies how much time the player has to answer all the questions. The game is over when time runs out. A value of 0 in the Game Time parameter results in no time limit. That is, the player will have an infinite amount of time to play the quiz game. If you have a value greater than 0, then the component displays a Time Remaining field that shows the time counting down from the value you specified in this parameter. If the value for the Game Time parameter is 0, then the Time Remaining field is not displayed.

Question Time The Question Time parameter specifies how much time the player has to answer each individual question. If time runs out, the game moves on to the next question. A value of 0 in the Question Time parameter results in no time limit for each question. That is, the player will have an infinite amount of time to answer each question. If you have a value greater than 0, then the component displays a Question Time field that shows the time counting down from the value you specified in this parameter. If the value for the Question Time parameter is 0, then the Question Time field is not displayed.

Questions Per Quiz The Questions Per Quiz parameter specifies how many questions there are in the quiz game. The Quiz component randomly displays the questions from the text file that you specify in the File Name parameter. If you have more questions in the text file than you specify in the Questions Per Quiz parameter, then the component randomly selects the number of questions you specified from the available questions in the text file. For example, if you specify 10 questions in the Questions Per Quiz parameter and you have 25 questions in your text file, then the component will randomly select 10 questions from the 25 questions.

One Chance The One Chance parameter specifies whether or not you want the player to have more than one chance to get the correct answer. If the One Chance parameter is set to True, then the player has only one chance to get the answer right. If the player gets the answer wrong when the One Chance parameter is set to True, then the game moves on to the next question. If the One Chance parameter is set to False, players can guess until they have answered the questions correctly.

Show Correct The Show Correct parameter works in conjunction with the One Chance parameter. If the One Chance parameter is set to True and the Show Correct parameter is set to True, then the component displays the correct answer when the player gets the question wrong. If the One Chance parameter is set to True and the Show Correct parameter is set to False, then the component does not display the correct answer when the player gets the question wrong.

Time To Display Correct Answer The Time To Display Correct Answer parameter works in conjunction with the two previous parameters (One Chance and Show Correct). If both of the two previous parameters are set to True, the Time To Display Correct Answer parameter specifies how long the correct answer is displayed when the player gets the answer wrong. The correct answer is displayed for the duration of the value set in this parameter, and then it moves on to the next question.

Show Total Quiz Number The Show Total Quiz Number parameter controls whether or not a text readout is displayed. The text readout displays the number of the question that is currently being displayed and how many total questions there are. For example, if you are currently answering question 3 out of 10 questions, the readout will display "Question #3 out of 10." Setting this value to False removes this readout.

Correct Sound, Wrong Sound, Waiting Sound, and Question Time Expired These parameters specify the identifier or "linkage" names for sound files that will be played in certain circumstances:

PARAMETER

SOUND PLAYED WHEN


Correct Sound

The player answers the question correctly.

Wrong Sound

The player selects the wrong answer for the question.

Waiting Sound

The game is waiting for you to answer a question.

Question Time Expired

Time is expired for the question.

If you leave a field blank, no sound is played in that situation. The sound will also not play if you enter the wrong value for the identifier in a field or if you forget to set the identifier for a particular sound effect.

The Waiting Sound should be a looping sound; it is designed to give the player a auditory clue that time is passing. The Question Time Expired sound is only played if you have entered a value other than 0 for the Question Time parameter.

The first parameter in the custom UI for the Quiz component already references the quiz.txt file. This is a variable because you may need to name the text file something other than quiz. For example, if you use this component for several quizzes on your site, you might want to use a different text file for the different quizzes. If so, they can't all be named quiz.txt. For now, however, let's leave the value for the File Name parameter as Quiz.txt.

Change the value of the Game Time parameter to 100 and change the value of the Question Time parameter to 10 (see Figure 9.4). When you are done, close the Component Parameters panel and test the movie.

click to expand
Figure 9.4: Setting the Game Time and Question Time parameters

Now when you play the game, you will notice there are two timers on the top left and top right of the game. The timer on the top left is labeled Time Remaining, and it counts down from 100. The timer on the top right is labeled Question Time, and it counts down from 10 for each question. If you do not answer each question within 10 seconds, you will see the message "Too Late" appear on the screen for a moment before the game moves on to the next question (Figure 9.5). After you have tested the movie to see the results of the changes, close the test movie window.

click to expand
Figure 9.5: The game flashes a "Too Late" message when time has run out.

As you can see by this simple example, the Quiz component's parameters allow you to adjust the timing and pacing of the quiz game. You can set the quiz game to quiz the player on 100 questions or on only two. You can set the quiz to have a time limit of 3 minutes or give the player unlimited time to play the game. You can adjust the game so that the player has to answer correctly before moving on to the next question, or you can force the game to move on to the next question whether or not the player has selected a correct answer.

You can edit and adjust the parameters and test the results until the game functions as you prefer. Editing the values in the component's parameters is significantly easier than rooting around for the actual variables in the game's code in order to accomplish the same thing.

You can also edit the graphics and the audio in the same way we have discussed in previous chapters. For example, you don't need to settle for the yellow buttons used for selecting the questions. You can edit the movie clips that contain the artwork and leave their instance names intact.

For example, go to frame 5 on the main Timeline and select the movie clip that contains the button labeled A. Open the Properties panel and notice that the movie clip has the instance name "answer1" (see Figure 9.6). You can edit this movie clip and change the graphics or the font to any image or font you want. The important thing is that you make sure that the movie clip named "answer1" is still on the stage when you play the movie, because the Quiz component needs that movie clip to function properly.

click to expand
Figure 9.6: You can edit the movie clips to change the graphics, but be sure to leave the instance names for the movie clips as they are.




The Hidden Power of Flash Components
The Hidden Power of Flash Components
ISBN: 0782142109
EAN: 2147483647
Year: 2002
Pages: 111

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net