We've already created the basic shell of the movie, which is located on the CD-ROM included with this book. (We assumed you could do this yourself, but we did it for you to save you some time.) Begin by taking a few moments to look over the movie. In this lesson you'll finish setting it up so you can begin the primary development.
1. | Open dante_quiz.fla. |
The file is already in your site, in the dante/flash folder.
2. | Review the timeline, stage, and Library. |
Notice that the movie is divided into five sections. If you move the frame indicator, you'll see that the movie is divided into five screens, with one question for each screen. You'll also notice that screens 4 and 5 are completed, both in terms of the interface and the ActionScript attached to Frames 30 and 40 in the actions layer.
The Library already contains a number of assets, including the Button and RadioButton components. Also in the Library is a movie clip called warningDialog, which is a generic error message that you'll instantiate and program later in this lesson.
3. | Click Frame 1 of the actions layer, and press F9 to open the Actions panel. |
There's no script at this point, but that's about to change.
4. | Type the following code in the Actions panel: /******************* Enables us to access the ActionScript for components using just their names (e.g., Button), as opposed to their full pathnames (e.g., mx.controls.Button). It also activates code hints. *******************/ import mx.controls.RadioButtonGroup; import mx.controls.Button; /****************** Initializes the movie; that is, it sets the movie's begin state. * It stops the movie on the first frame. ******************/ stop(); |
As you've probably guessed, everything inside the /* and */ is a comment. Flash ignores comments, but they're useful for readers, including yourself, in the event you forget how a section of code works. You can skip the step of entering the comments if you wish, but documenting your code is an important practice.