Organizing ActionScript code
33
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 by 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 common 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.
When you’ve stopped the SWF file 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.
Organizing ActionScript code
You may attach scripts to keyframes and to object instances (movie clips, buttons, and other
symbols). However, if your ActionScript code is scattered over many keyframes and object
instances, debugging your application will be much more difficult. It will also be difficult to
share your code between different Flash applications. Therefore, it’s important to follow best
practices for coding when you create ActionScript in Flash.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...