Search code examples
actionscript-3volume

Need Volume adjust on as3 tips


This is my code for sound in my program. I'm not sure if the mySound and mySound2 are necessary. They are different music tracks but will not be playing at the same time. There are some errors like the incorrect sequence ones, but I can fix those. I'm worried more about the volume because it tends to be a little loud without the volumeAdjust. The thing that I'm worried about is that no matter what I set the volumeAdjust.volume to it does not change anything about the volume. I've tried stuff like

volumeAdjust -= .5 

not in the function but as a global variable/object, but that doesn't work either.

Here is the essential code of it, but bear in mind the channels are already declared variables globally.

var volumeAdjust:SoundTransform = new SoundTransform();
var mySound:Sound = new Sound();
var mySound2:Sound = new Sound();
volumeAdjust.volume = 0.5;
channel.soundTransform = volumeAdjust;
channel2.soundTransform = volumeAdjust;

Solution

  • So I thought I would just add the solution I came up with which involves Organis's tip. I didn't think that it would work because the sounds are short, but putting the volume adjust right after the .play(); line does work I'm thinking almost immediately so. I was unsure how well the program would take the quick sound and adjust it quickly enough but it did work the way I wanted it to.