【正文】
any other application that presents remote data with a graphically rich interface. Depending on your project and your working style, you may use these steps in a different order. As you bee familiar with Flash and its workflows, you will discover a style of working that suits you best. About ActionScript and events In Macromedia Flash Basic 8 and Macromedia Flash Professional 8, ActionScript code is executed when an event occurs: for example, when a movie clip is loaded, when a keyframe on the Timeline is entered, or when the user clicks a button. Events can be triggered either by the user or by the system. Users click mouse buttons and press keys。 the system triggers events when specific conditions are met or processes pleted (the movie loads, the Timeline reaches a certain frame, a graphic finishes downloading, and so on). When an event occurs, you write an event handler to respond to the event with an action. Understanding when and where events occur will help you to determine how and where you will respond to the event with an action, and which ActionScript tools should be used in each case. Events can be grouped into a number of categories: mouse and keyboard events, which occur when a user interacts with your Flash application via the mouse and keyboard。 clip events, which occur within movie clips。 and frame events, which occur within frames on the Timeline. Mouse and keyboard events A user interacting with your Flash movie or application triggers mouse and keyboard events. For example, when the user rolls over a button, the on (rollOver) event occurs。 when a button is clicked, the on (press) event occurs。 if a key on the keyboard is pressed, the on (keyPress) event occurs. You can attach scripts to handle these events and add all the interactivity you desire. Clip events Within a movie clip, you may react to a number of clip events that are triggered when the user enters or exits the scene or interacts with the scene using the mouse or keyboard. You might, for example, load an external SWF file or JPG image into the movie clip when the user enters the scene, or allow the user’ s mouse movements to reposition elements in the scene. Frame events On a main or movie clip Timeline, a system event occurs when the playhead enters a keyframe— this is known as a frame event. Frame events are useful for triggering actions based on the passage of time (moving through the Timeline) or for interacting with elements that are currently visible on the stage. When you add a script to a keyframe, it is executed when the keyframe is reached during playback. A script attached to a frame is called a frame script. One of the most mon uses of frame scripts is to stop the playback when a certain keyframe is reached. This is done with the stop() function. You select a keyframe and then add the stop() function as a script element in the Actions panel. Once you’ ve stopped the movie at a certain keyframe, you need to take some action. You could, for example, use a frame script to dynamically update the value of a label, to manage the interaction of elements on the stage, and so on. For more information, see Chapter 5, “ Handling Events,” on page . Organizing ActionScript code You may attach scripts to keyframes and to object instances (movie c