Copy link to clipboard
Copied
Hey guys,
I'm getting this silly little problem. I'm making a sound play and I'm trying to change it's volume. I've done this many times before and got it to work, but in this script for some reason it's not working. The script looks like this :
package {
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
public class Main
{
var createSound:Create;
var createChannel:SoundChannel;
var createTransform:SoundTransform;
public function Main()
{
createSound = new Create();
createChannel = new SoundChannel();
createTransform = new SoundTransform();
createTransform.volume = 0.5;
createChannel.soundTransform = createTransform;
createChannel = createSound.play();
}
}
}
For some reason, it plays the sound, but at full volume no matter what value I put in the createTransform.volume variable. I've gotten almost the same exact code working in other games I've made, I dunno why it isn't working in this one
try:
...
package {
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
public class Main
{
var createSound:Create;
var createChannel:SoundChannel;
var createTransform:SoundTransform;
public function Main()
{
createSound = new Create();
createChannel = new SoundChannel();
createTransform = new SoundTransform();
createTransform.volume = 0.5;
// in this order
Copy link to clipboard
Copied
try:
package {
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
public class Main
{
var createSound:Create;
var createChannel:SoundChannel;
var createTransform:SoundTransform;
public function Main()
{
createSound = new Create();
createChannel = new SoundChannel();
createTransform = new SoundTransform();
createTransform.volume = 0.5;
// in this order
createChannel = createSound.play();
createChannel.soundTransform = createTransform;
}
}
}
Copy link to clipboard
Copied
haha I'm an idiot, thanks kglad!
Copy link to clipboard
Copied
(welcome to the club - and, you're welcome.)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now