Skip to main content
Participating Frequently
August 17, 2015
Question

Volume Slider not working as expected

  • August 17, 2015
  • 2 replies
  • 815 views

Problem: The volume doesn't seem to change after about the first third of the bar. In other words, if I set the slider all the way to the left, the volume is muted. As I start moving the slider to the right, I can easily tell it is getting louder...but it seems to get the loudest when I am only about a third of the way toward the right (if this were a volume knob that went from 0 to 10...it would be its loudest about 3). I cannot distinguish a volume change in the last two thirds of the bar.

I am using the slider component, and have the maximum set to '1', the snapInterval set to "0.01", and the value set to '1'.

I am using the follow code:

import fl.events.SliderEvent;

import flash.media.SoundTransform;

var voltransform:SoundTransform = new SoundTransform();

Slider.addEventListener(SliderEvent.THUMB_DRAG,changevol);
function changevol(event:SliderEvent):void{
voltransform.volume = Slider.value;
SoundMixer.soundTransform = voltransform

}

Any ideas why this happens? Or a fix?

Thanks

This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
August 17, 2015

change the instance name of your slider to slider_sp in the properties panel.  then use the following code:

import fl.events.SliderEvent;

import flash.media.SoundTransform;

var voltransform:SoundTransform = new SoundTransform();

slider_sp.minimum=0;

slider_sp.maximum=1;

slider_sp.addEventListener(SliderEvent.THUMB_DRAG,changevol);


function changevol(event:SliderEvent):void{
voltransform.volume = slider_sp.value;
SoundMixer.soundTransform = voltransform

}

Participating Frequently
August 17, 2015

Thanks again for helping.

When I just change the instance name and replace the code, I get the same effect that I have been getting.

Do I need to change any of the values that are set in the properties box? I tried leaving them as I have them listed above, and I have tried with them zeroed out and still get the same thing.

This is not a huge deal, as I was trying to add the slider to an existing soundboard I created a few years ago. I was updating some of the selections and thought I would try to add a volume control.

I don't know if it makes a difference, but I do not have any of the songs imported. I just have the buttons point to a local directory (I only use this swf file locally) of songs.

I just use this code for the buttons (edited for each song):

var fl_ToPlay_3:Boolean = true;

function fl_ClickToPlayStopSound_3(evt:MouseEvent):void

{

    if(fl_ToPlay_3)

    {

        var s:Sound = new Sound(new URLRequest("C://GAME DAY MUSIC/ARE YOU READY FOR SOME FOOTBALL.mp3"));

        fl_SC_3 = s.play();

    }

    else

    {

        fl_SC_3.stop();

    }

    fl_ToPlay_3 = !fl_ToPlay_3;

}

kglad
Community Expert
Community Expert
August 17, 2015

show the slider code you're using.

kglad
Community Expert
Community Expert
August 17, 2015

your max slider value is probably 10 (or, at least, greater than one) so you're going to get to the max volume (1) pretty quickly.

use trace(Slider.value) to confirm that's the problem then assign Slider's max value to be one.

Participating Frequently
August 17, 2015

I am a novice to this, but what I have read suggests the maximum value needs to be set to "1". I have tried "10" and "100", but I end up with distortion when playing an mp3.

I am not even sure how to use trace(Slider.value)

Thanks