Return to Snippet

Revision: 15084
at June 23, 2009 17:50 by echamussy


Updated Code
import flash.media.SoundMixer;
import flash.media.SoundTransform;


//All sound channels
SoundMixer.soundTransform = new SoundTransform(.5);



//Without a sound channel:
var sTransform:SoundTransform = new SoundTransform();
sTransform.volume = volumeLevel;
musicSoundChannel.soundTransform = sTransform;


//With a sound channel:
protected static var musicSoundChannel:SoundChannel;
...
var urlRequest:URLRequest = new URLRequest(url);
if (musicSoundChannel != null){
	musicSoundChannel.stop();
}
musicSound = new Sound();
musicSound.load(urlRequest);
if (musicSound != null){
	musicSoundChannel = musicSound.play();
}

var sTransform:SoundTransform = new SoundTransform();
sTransform.volume = volumeLevel; //Volume level is a Number between 0 and 1
musicSoundChannel.soundTransform = sTransform;

Revision: 15083
at June 23, 2009 17:48 by echamussy


Initial Code
import flash.media.SoundMixer;
import flash.media.SoundTransform;


//All sound channels
SoundMixer.soundTransform = new SoundTransform(.5);



//Without a sound channel:
var sTransform:SoundTransform = new SoundTransform();
sTransform.volume = volumeLevel;
musicSoundChannel.soundTransform = sTransform;


//With a sound channel:
protected static var musicSoundChannel:SoundChannel;
...
var urlRequest:URLRequest = new URLRequest(url);
if (musicSoundChannel != null){
	musicSoundChannel.stop();
}
musicSound = new Sound();
musicSound.load(urlRequest);
if (musicSound != null){
	musicSoundChannel = musicSound.play();
}

Initial URL

                                

Initial Description

                                

Initial Title
Volume control AS3

Initial Tags

                                

Initial Language
ActionScript 3