• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 8. Controlling Sound > Attaching Sounds

Attaching Sounds

When you have multiple imported sounds in your Library, you have to convey to the sound object which sound to play and control. You identify sounds in the Library using the Linkage option, just as you did in Chapter 7 when you attached a movie clip from the Library to a movie-clip instance on the Stage. In addition to identifying your sound, the Linkage option exports it with the SWF file so it will be available when called by the sound object. Once the sound is identified with the Linkage option, you attach it to the sound object using the method attachSound.

To attach a sound to the sound object:

Continuing with the previous task, select your sound file in th e Library.

From the Options menu, choose Linkage (Figure 8.4).

Figure 8.4. Choose the Linkage option from the Library for each sound you want to attach.

The Symbol Linkage Properties dialog box appears.

From the Linkage radio buttons, select Export this symbol. In the Identifier field, enter a name to identify your sound. Click OK (Figure 8.5).

Figure 8.5. This sound is called narration and will be included in the exported SWF file.

Flash exports the selected sound in the SWF file with the unique identifier so that it is available to play when called by the sound object.

Select your button on the Stage, and open the Actions panel.

Select the new Sound statement in the Actions List.

By selecting the new Sound statement, you make sure that your next ActionScript statement appears under it.

Choose Actions > evaluate.

In the Expression field, enter the name of your sound object, and then choose Objects > Sound > attachSound.

The attachSound method appears in the Expression field in the Parameters pane with the argument idName highlighted (Figure 8.6).

Figure 8.6. The attachSound method requires the argument idName, which is the identifer of your sound in the Library.

In the Expression field, replace the argument idName with the identifier of your sound file within quotation marks (Figure 8.7).

Figure 8.7. The method attachSound attaches the sound identified as narration to the mySound sound object.

It's very important that you specify the sound file identifier within quotation marks. They tell Flash that the word is the literal name of the identifier and not an expression that it must evaluate to determine the name of the identifier.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint