Toxiclab.org

Sound on/off

24.12.2005, 16:26
Submited in: Flash | Total Views: 72073

In this lesson you will learn how to create sound on/off button in flash. Using that button, you can turn on and turn off sound. You can use this button if you have a sound on your page.

Step 1

Click on file – import (ctrl+R) and choose some loop for import file. Now that file is accesible in the library that you open with  Ctrl+L or by pressing F11 key on the keyboard.





Step 2


Choose  Insert – New simbol (ctrl+F8) and under Behavior choose Movie Clip, give name and press OK.



Step 3

Now, under movie clip, write sound on and sound off. See the picture below.



Mark the text and press two times ctrl+B key to break it.

Step 4

Click on Arrow tool (V) and mark just sound on.

 

Step 5

When you have marked sound on, press F8 (Convert to Symbol) to convert "Sound on" into a Button. See the picture below.



Step 6

Double-click on the button on stage with the Selection tool (V).You should now be inside the button






Step 7

Now you can modify button as you wish, yust be carefull that on the hit frame you fill the "music on" with desired color. Look at the picture bellow!





Step 8

Repeat step 4 – 7 but for this time, do that for music off.

Step 9

Step outside of the button and go back to the movie clip.



Step 10

Insert a new layer and name it loop. After that create again a new layer and name it actionScript. See the picture below.



Step 11

Choose layer loop from Library (ctrl+L), and using the "drag and drop" technique, move it on the stage. Click on first frame of loop layer, open the Properties Panel  (Ctrl+F3) and for repeat option set some big number. See the picture below.



Step 12

Using the mouse, select the second frames of all layers. See the picture below.



Step 13

Click on  the first frame of layer button, select the button «music on» and press ctrl+B key once time to break apart it. Then change it's color to some lighter. See the picture below.



Step 14

Click on the second frame of layer button and repeat step 13, but this time do that for the "music off" button.

Step 15

Now it's time for a little action script and we're done.

Click on frame 1 of actionScript layer, open the Action Script Panel (F9) and paste this script:

stop();

Click then on second frame and paste this script:

stopAllSounds();

After that click on the first frame of  layer buttons open again the Action Script Panel and paste this script:

on (release) {
  nextFrame();
}

Then click on the second frame and paste this script:

on (release) {
  prevFrame();
}


Step 16

Get back on the main scene (Scene 1) and using the mouse, move that movie clip from the Library on the stage.

That's all.

Test your Movie (Ctrl+Enter)

Enjoy!

Download example (56 KB)

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category




Most popular tutorials


Resources Worth visiting


Friends