H  15  16.1  16.2  17  18  19  20  21  22  23 

Hands-On: Flash MX 2004 Working with Sound File

Exercise 17: Using ActionScript Behaviors with Sound Files

Sounds could be important to your Web page, and let’s assume that you will be adding sound. Now you should learn how to control your sounds with Flash MX 2004 ActionScript Behaviors.

  1. Re-load the testSharedSounds.fla file or open a new file and add a sound file to the Library.
  2. Open your Library [F11] and select an audio file from what is available.
  3. Click the Library Option button, and then click Linkage.
  4. Select Export for ActionScript.
    Linkage Properties dialog box.
  5. Enter a distinctive name for the identifier field or use the default name.
  6. Leave the other fields at their default values, and then click OK.
  7. The Common Libraries panel Add a set of buttons to Start and Stop the Music on the Stage. (You may choose to add the sound to the Timeline instead, if you do, skip the steps outline how to put a button on the Stage.)
  8. Add a layer to hold the buttons on the Timeline and rename it buttons.
  9. Select Window > Other Panels > Common Libraries > Buttons.
  10. Choose the Playback folder and then select both a Playback - Play and a Playback - Stop button for the Stage.
  11. Button choices from the Common Library Select the Playbutton object on the Stage or Timeline keyframe if you have no buttons.
  12. Load Sound from Library

  13. Click the Window menu, point to Development Panels, and then click Behaviors.
  14. Click the Plus sign +, located in the upper-left portion of the Behaviors panel, point to Sound, and then click Load Sound from Library.
  15. Enter the name of the audio file in the Linkage ID field.
  16. Enter a unique name in the instance field of the Properties panel. I called mine comfort for the comfortable.wav file I’m using.
    Properties Inspector for the Play button
  17. Load Sound from the Library dialog box. Select Play This Sound When Loaded.
    Click OK.
  18. Note: If the audio file was added to a Timeline frame, the event field will be disabled.
  19. Click the Control menu, and then click Test Movie to test the ActionScript, or use [Control] + [Enter].
  20. Your button will play the sound file when pressed, however, the Stop button hasn’t been set up yet, so that is next.

 

 

Back to Top