We now build the interactive round. In this case, the round has three possible states: Start: Present the question and wait for response. Win: Response was correct. Lose: Response was incorrect. Note We believe that strict discipline is sometimes liberating. Flash allows code to be embedded in any frame and any layer and to be attached to each instance of any object. This much freedom permits the programmer to be creative. Code can be tucked into many corners, and a clever programmer can devise a tricky game of hide and seek. Hide and seek is fun in the back yard. But it is annoying at the computer and deadly when many people are working together and facing real deadlines. The challenges of making good software together are numerous enough without inventing more. So we direct our creativity elsewhere and approach code placement with this strict discipline: If you use ActionScript on any frame, put it in a reserved layer called Code. Put labels on the top layer ” in the Code layer if there is one, or even a Label layer. Sounds should also be in their own layer(s). Object actions, such as button actions, are exceptions. If the button is going to do anything, an event handler must be attached to the object instance, not to a keyframe in a timeline layer. Any object action should be extremely simple ”it should invoke script visible on this timeline. (This means calling a local function or going to a particular frame.) Like the button, the Round will establish each of the three states as a separate frame. While Flash frames often represent tiny slices of time in the progress of an animation, they frequently are used instead to represent static screens and as targets in finite-state logic. Often, they are both. Make a Movie Clip symbol using I NSERT /N EW S YMBOL . Create a Code layer. Like the Sound layer earlier, this is an ordinary layer to which we give a special name . Other than as a reminder for ourselves (and a hint to fellow programmers) layer names have absolutely no meaning. |