|
|
|
|
Author |
Message |
kasselbiddy
Age: 41
Joined: 24 May 2012
Posts: 14
|
|
Here is how you go about setting the volume of sound in Flash. There are two ways of setting volume, either on a per-channel basis or globally across all channels. Besides, here is a tutorial about how to convert SWF to MOV on Mac with a Mac SWF to MOV converter.
Before we dive in it is worth taking a quick look at the four main classes used when manipulating sound in Actionscript 3.0.
* Sound
An object representing an individual sound. This may be a sound effect or music loop.
* SoundChannel
A channel which plays a single Sound object.
* SoundTransform
Class used to manipulate the volume and/or panning of a sound.
* SoundMixer
A class containing static methods for controlling the global output of sound in a SWF.
Setting the volume of an individual sound
We can set the volume of a single sound channel at two distinct occasions, when the SoundChannel is instantiated as a result of calling the play method of a Sound instance, or we can alter the volume of an already existing SoundChannel.
Volume is set via an instance of the SoundTransform class. A SoundTransform instance is simply applied to the soundTransform property of a SoundChannel. Here we apply a SoundTransform instance with a volume of 0.5 to an existing SoundChannel called myMusicSoundChannel.
myMusicSoundChannel.soundTransform = new SoundTransform(0.5);
Note the volume value is specified as a number between 0 (silent) and 1 (full volume).
Next we set the volume of a SoundChannel during it’s initialization. The Sound instance, mySound, is set to play a single time with a volume of 0.5.
var mySoundChannel:SoundChannel = mySound.play( 0, 0, new SoundTransform(0.5) );
Setting volume globally
Setting the global volume of sound in your SWF is very similar to setting the volume of a single sound. The main difference is that we aren’t manipulating a single SoundChannel instance, rather we use the SoundMixer class.
SoundMixer.soundTransform = new SoundTransform(0.5);
|
|
|
|
Last edited by kasselbiddy on Sun Dec 15, 2013 11:14 pm; edited 1 time in total
|
|
|
|
|
ivy00135
Joined: 06 Nov 2012
Posts: 49808
|
|
|
|
|
|
|
View next topic
View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|
|
|
|
|
|