Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Creative Suite

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Adding Sounds

Using sound in games goes beyond aesthetics; sound has a purpose. It provides feedback to your user when he is interacting with your game. Sound is a key element to successful game development and design.

For this project, you will use two sound effects that you will pull from the Library using ActionScript. One is triggered each time the character collects a balloon, and the other one is triggered when the game is over. The two sounds are located in the Sounds folder in the Library and are called: grab and done.

  1. Right-click/Ctrl-click on the grab sound and select Linkage.

  2. Select the Export for ActionScript and the Export in First Frame options. In the Linkage Properties panel, type the identifier name grab.

Figure 5.19Figure 5.19

  1. Repeat Step 2 for the done sound effect. In the Linkage Properties panel, type the identifier name done.

  2. Go to the first frame in the sounds layer and open the Actions panel. Add the following script:

    Listing 5.14

    //The sounds layer creates two new sound objects, 
    //"grab" and "done", and attaches linked sounds 
    //from the library.
    
    var grab_sound:Sound = new Sound();
    var done_sound:Sound = new Sound();
    grab_sound.attachSound("grab");
    done_sound.attachSound("done");

    This script pulls the two sounds from the Library and attaches each one to a sound object using attachSound(). This method offers more control and flexibility (as opposed to placing each sound on a frame). You can now manipulate the sounds using the methods and properties of the Sound object and call them anywhere in the movie, as demonstrated in the next section.

    Once again, adding the suffix _sound will reference the properties of the built-in Sound object in the Code Hints panel.

  3. Save your work.

  • + Share This
  • 🔖 Save To Your Account