| Creating Sound Control
This tutorial requires a basic knowledge of Flash. You must know how
to create buttons, and work with Frames and Layers.
For this tutorial, you will need a sound loop - you can find plenty all
over then net, or do what I did and create your own. I just tossed a very
quick and easy loop into this tutorial.
Start a new Flash Document and add two layers. Name them as follows:
Actions
Controls

Import your sound file (Control + R - Choose Loop).
Open the Actions Box (F2).

Put in these Commands on the first frame of the Actions layer.
stop();
And, on the second frame of the Actions layer put in these commands:
stop();
stopAllSounds();
Now, click on Frame one of the Actions layer and press Control + F3 to
open your Properties toolbox. In the sound dropbox, select your loop as
the Sound.

We won't be adding any effects to the sound for this tutorial, but you
can play with them later on. Set the loop to 100, or a number that you
think will suffice for your Flash File.
Test the movie, if you hear the sound looping continuosly, we can move
on to the next step.
Create two seperate buttons, one for Stop and one for Start. There will
be no need to add any special Action Scripting for this, just the standard
Go To and Play commands.
In the Control Layer, place your buttons in frame one. Now, Insert a
KeyFrame on frame two, creating a duplicate of the first frame - this
allows for a seamless transition from Frame 1 to Frame 2.
Click the first frame of the Actions Layer, and we will start to add
the actions to the buttons.
In the first frame, only the Stop button needs to be active. I usually
just select the Start button and hit Control + B to break it apart.
Select the Stop button and press F2, opening your Action Toolbox. Insert
this command:
on (release) {
gotoAndPlay(2);
}
Now, click on the second from on the Actions layer. I suggest, once again,
that you disable the Stop button in this Frame.
Select the Start button, and add these commands:
on (release) {
gotoAndPlay(1);
}
Now, we have total control over our sound.
Test the movie, Control + Enter, and see if you are able to Stop them
on command, and Restart. |