Basic Interactivity
463
Using Buttons to Control Timelines
Using Buttons to
Control Timelines
Most Flash creations employ a mixture of
interface objects: button symbols, button
components, and movie clips. You can script
a button (or button component) to start and
stop the playback of a movie clip, or make
the playhead jump to a speci c frame in a
movie clip.  e key is to specify the correct
target path.
The Mystery of Target Paths
All Flash creations have a certain amount of structural complexity. Even a simple movie like
the one created with ButtonActionsMaster has a hierarchy of nested objects. ( e Timeline
you see when you open a Flash document in the authoring environment is actually a movie-
clip object, so any objects on this main Timeline are considered nested objects.) But the
structure gets really complex when you nest interactive objects inside other interactive
objects—a button inside a movie clip, a movie clip inside a movie clip, a button inside a movie
clip inside a movie clip, and so on.
A nested object is known as a child object, and the object containing that child is known as
the parent object. As long as each parent and child has an instance name, it doesn’t matter
how complex the family relationship gets. You can create a script that manipulates any of the
nested objects.  e key is to identify the target object’s place in the hierarchy of Timelines
using a target path.
ere are two types of target paths: relative and absolute. A relative target path starts with the
target object and describes its relationship to other Timelines in the hierarchy—indicating,
for example, that the target is me, or it’s one level above me; or it’s within me, one level down.
An absolute target path starts with the highest-level Timeline and works its way down the
hierarchy until it reaches the target object.
Just to complicate things, however, ActionScript 3.0 introduces a new type of interactive
object, the sprite. A sprite is similar to a movie clip, but it has no Timeline and no frames.
All of the animation and interactivity of a sprite happens because of scripting. Sprites can
also be nested and have hierarchical relationships. And you use target paths to identify them.
When you write target paths, you need to distinguish between sprite objects and Timeline-
based objects (movie clips) by using the code
as sprite
or
as movieClip
—as shown in the
examples below. (In this book, we work only with Timeline-based objects.)
continues on next page

Get Adobe Flash CS4 Professional for Windows and Macintosh: Visual QuickStart Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.