Building a Multiple-Choice Quiz
Now that we’ve explored the basic principles of ActionScript, let’s apply those principles in the context of a real Flash movie. We’ll start our applied study of Flash programming by creating a multiple-choice quiz using very simple programming techniques, most of which you’ve already learned. We’ll revisit our quiz in later chapters to see how it can be improved after learning more advanced programming concepts. We’ll eventually make the code more elegant so that it’s easier to extend and maintain, and we’ll add more features to our quiz so that it can easily handle any number of questions.
The finished .fla file for this quiz may be found in the online Code Depot. This is a lesson in Flash programming, not Flash production. It is assumed that you are already comfortable creating and using buttons, layers, frames, keyframes, and the Text tool. The quiz shows real-world applications of the following aspects of ActionScript programming:
Variables
Controlling the playhead of a movie with functions
Button event handlers
Simple conditionals
Text field variables for on-screen display of information
Quiz Overview
Our quiz, part of which is shown in Figure 1.4, will have only two questions. Each question comes with three multiple-choice answers. Users submit their answers by clicking the button that corresponds to their desired selections. The selections are recorded in a variable so that they may be used to grade the user’s score. When all the questions have been ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access