Simple way to stop or decrease volume of sound in flash or make volume control

The simplest way to control sound is to use attach sound command.

First you have to import sound using control + r.

Then goto library and right click and select properties of the sound file select and check “Export for ActionScript” then put a name in the Identifier.

The following script sets up a sound object:

s = new Sound();
s.attachSound(“mySound”);
s.start(1,100);

The start(); can be used the this way:
start (offset, loop);

The final line of the code starts the music after ‘1 second’ and loops it ‘100 times’. Replace the figure 100 with whatever number you want to represent your loops.

To set the volume you would:

on (release) {
s.setVolume(25);
}

This will decrease the volume by 75%.

To totally stop sound

on (press) {
_root.s.stop();
}

No related posts.

Leave Your Response

* Name, Email, Comment are Required