10.5. Creating a Basic Interface to Control Timeline Playback
Problem
You want to create a button bar to give users control over movie playback.
Solution
Create the buttons or use premade buttons from the common library. Then use button event handler methods to call the stop( ), play( ), and gotoAndStop( ) methods as appropriate.
Discussion
You can create a set of buttons to give control over playback to the user. Whether your movie contains animation, video, or even a series of slide-like pages with a voice-over soundtrack, playback controls make it possible for users to stop and start the movie, fast-forward over parts they’ve seen before, or rewind to parts they want to see again.
Creating a set of playback controls involves two major steps: creating the buttons that will serve as the interface, and writing the code that will make the buttons functional.
For a basic set of controls, you will need at least three buttons (or movie clips that handle button events)—one for stopping the playback, one for pausing the playback, and one for resuming the playback. Refer to Chapter 9 for more information about creating buttons or movie clips that act like buttons. Optionally, one fast way to put together an interface is to use one of several button sets available in the Common Libraries (Window → Common Libraries → Buttons).
After you’ve created the buttons, next create instances on the stage. Make sure to give them each instance names. The example code in this recipe uses the instance names ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access