Lesson 17. Scripting for Sound

Few things enhance the way we experience something more than sound. Not only does sound provoke an almost instantaneous emotional response, it also provides dimension. When standing in the middle of a crowded room, you can close your eyes and easily determine the relative position of people and clattering items just by listening. In a Flash presentation you can employ sound to provide your user with context as well as to create an engaging experience.

Flash's sound controls will make this basketball sound like the real thing.


A thorough understanding of how to control sound dynamically is key to creating everything from games to custom MP3 players. In this lesson, we'll demonstrate Flash's versatile sound controls by emulating a bouncing basketball inside an arena. The user can drag the ball within a predefined area of the screen. As the ball is dragged, the volume and panning of the bounce will be controlled dynamically to indicate its current location. You'll also see how Flash enables you to add and control sounds in your movie without placing them on the timeline.


In this lesson, you will:

  • Explore the uses of sound with ActionScript

  • Learn how to create a Sound object

  • Drag an object within a visual boundary

  • Control the volume of a Sound object

  • Control the panning of a Sound object

  • Add sounds to your movie by using the attachSound() method

  • Start, stop, and loop sounds dynamically


This lesson takes approximately one and one half hours to complete.


Starting File:


Completed Project: