Organizing Actionscript Code - MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

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
function. You select a keyframe and then
stop()
add the
function as a script element in the Actions panel.
stop()
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.

Organizing ActionScript code

33

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents