VirtualMV/Flash12 (CS6)/Journal/Content/Toggle Background Music

Objectives
By the end of these exercises you should be able to:
 * Add sound to an invisible movieclip
 * Place an ON and an OFF button on the movie with code behind
 * Toggle the sound on or off when the buttons are pressed.

Open a new Flash file
1. Save as toggle.fla

Import your audio to the Flash Library
2. Locate media files, use WAV or MP3 format and drag into Flash Library.

Creating an invisible movie clip
3. Create a new Layer called invisibleMC

4. Draw a small circle on the stage & CONVERT TO SYMBOL

5. Rename as invisibleMC with an instance name mc

6. Click Movie Clip radio button & select OK

7. Hide movie clip on stage

Adding sound to the invisible movie clip
8a. Double click the invisible movie clip to open the clips editing panel 8b. Place a stop action in the first frame 8c. Place selected sound in the second frame 8d. Close the edit panel

Create an OFF button
9. Create any design on the scene

10. Add a label & name this OFF

11. Convert to a button

Add Action Script to OFF button
12. Put the following code on the button: on (release) { with (mc) { stopAllSounds ; } }

Create an ON button
13. Create any design on the scene

14. Add a label & name this ON

15. Convert to a button

Add Action Script to ON button
16. Put the following code on the button: on (release) { with (mc) { play ; } }

Ready to toggle
17. Export the movie to test

18. No background sound will play until the Play button is clicked on

19. Background sound will stop when the Stop button is clicked