
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
The Multiple-Choice Quiz, Take 3
|
271
Aside from storage and access, multidimensional arrays behave just like normal
arrays. We can use all of the Array methods to manipulate data stored in multidi-
mensional arrays.
The Multiple-Choice Quiz, Take 3
In Example 9-13, we revised the multiple-choice quiz from Chapter 1 (Examples 1-1
through 1-4). At that time, we improved the quiz code by creating reusable, central-
ized functions. Now that we’ve studied arrays, we can return to the quiz to make a
few more improvements. This time, we’ll use arrays to store both the user’s answers
and the correct answers for each question, making our code more succinct, legible,
and easier to extend if we want to add new questions.
The changes we need to make to the quiz take place on the scripts layer of frame 1,
where our main quiz code is located. Both the previous version and this updated ver-
sion of the quiz can be found in the online Code Depot. To see what improvements
we’ll make this time around, read through the code in Example 11-7, paying special
attention to the comments.
Example 11-7. A multiple-choice quiz, version 3
// Stop the movie at the first question.
stop( );
// ===================
// INIT QUIZ VARIABLES
// ===================
// Store a reference to the timeline that contains the quiz user ...