Accessibility

Design Center Tutorial

Creating dynamic sound controls in Flash


Russell Chun

 

Paul Robertson

H. Paul Robertson

Adobe
Blog

book cover

www.peachpit.com

 

Table of Contents

Created:
07 March 2007
User Level:
Advanced
Products:
Flash

One of the most effective uses of the Sound class and its methods is to create dynamic controls in Flash® 8 that allow the user to set the desired volume level or speaker balance. A common strategy is to create a draggable movie clip that acts as a sliding controller. By correlating the position of the draggable movie clip with the volume parameter of the setVolume() method, you can make the volume change dynamically as the viewer moves the movie clip.

For a vertical slider bar that controls volume, you must create two elements: the handle or slider and the track or groove it runs along (Figure 1). First, you create a movie clip called groove_mc. To make things easy, make the groove_mc movie clip 100 pixels high with its registration point at the bottom of the rectangle. Making the groove_mc 100 pixels high will make it simpler to correlate the position of the slider on the groove_mc with the setVolume() parameter. To create the draggable slider, create a movie clip called slider_mc and assign the startDrag() action with constraints on the motion relative to the groove_mc movie clip.

components of a volume control

Figure 1: The components of a volume control are the slider that moves up and down and the groove.

Requirements

To follow along with this article, you will need the following software:

Flash 8

Prerequisite knowledge:

Basic knowledge of Flash 8

About the authors

Russell Chun is a medical illustrator, writer, and teacher. He’s the author of this book’s previous editions, including Macromedia Flash MX 2004 for Windows and Macintosh: Visual QuickPro Guide. He develops instructional media for Benjamin Cummings, an educational science publisher. He has written numerous magazine articles on Flash, and he teaches Flash at the Graduate School of Journalism at the University of California at Berkeley.

 

H. Paul Robertson is an ActionScript developer/writer for the Platform Developer Documentation team at Adobe Systems. Previously he worked as a web applications developer and co-authored Macromedia Flash 8 Advanced: Visual QuickPro Guide (Peachpit Press, 2005) with Russell Chun. Paul is a Certified Flash Developer and holds a Masters degree in Instructional Systems Technology from Indiana University. When he's not programming web applications, writing about web applications, teaching about web applications, or updating his blog, Paul spends his time collecting kitchen gadgets and trying to achieve his three children's level of mastery of Legos, Star Wars trivia, and other equally important subjects.

Excerpted from “Macromedia Flash 8 Advanced for Windows and Macintosh: Visual QuickPro Guide” by Russell Chun and H. Paul Robertson © 2006. Used with the permission of Peachpit. To purchase this book, please visit www.peachpit.com.