Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Volume Slider not working as expected

New Here ,
Aug 17, 2015 Aug 17, 2015

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

TOPICS
ActionScript
663
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2015 Aug 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2015 Aug 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2015 Aug 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

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2015 Aug 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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2015 Aug 17, 2015

show the slider code you're using.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2015 Aug 17, 2015

Original is what I listed in first post...

After renaming the instance, I just copied and pasted what you told me above.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2015 Aug 17, 2015

drag the slider from one end to the other and paste the trace output from

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;

trace(slider_sp.value)
SoundMixer.soundTransform = voltransform

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2015 Aug 17, 2015

When moving left to right:

0

0

0.01

0.03

0.05

0.09

0.1

0.11

0.15

0.16

0.18

0.19

0.2

0.24

0.25

0.26

0.28

0.3

0.33

0.34

0.35

0.36

0.39

0.4

0.41

0.43

0.44

0.48

0.49

0.5

0.51

0.55

0.57

0.61

0.64

0.65

0.66

0.68

0.69

0.7

0.71

0.73

0.74

0.76

0.78

0.79

0.81

0.83

0.85

0.86

0.89

0.9

0.91

0.93

0.94

0.95

0.96

0.98

0.99

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2015 Aug 17, 2015

then the slider is working as expected.

do you have a snapInterval defined (greater than 0) so you can drag between the extreme left and right?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2015 Aug 17, 2015

Yeah...that is currently set at 0.01

I guess the slider is working as expected, but it is not doing what I expect.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2015 Aug 17, 2015

the volume of all your sounds will vary between 0 and 1 as you move the slider.  what do you expect?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2015 Aug 17, 2015

I would expect the volume to be mute when the the slider is all the way left (0) and as loud as it can be when all the way right (1)...and about half as loud is it can be when in the middle (.5)...and so on.

It is mute at 0, but as I slide to the right, it quickly gets to its loudest point about a third of the way to the right and remains there the rest of the slide.

If I move the slider along the right two thirds of the bar (either direction), the volume remains steady at max volume.

Over the left third, it works like I would expect it to over the full length of the bar...it incrementally lowers as I move left and incrementally raises as I move right...but anything further right that the left third is max volume.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2015 Aug 17, 2015

try a different sound.  maybe there's something wrong with the one you're using now.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2015 Aug 17, 2015

I have tried it on about 10 songs already...same result.

I will try it on a different computer, later and see if it might be the culprit.

Otherwise, I can live without it (have for years, anyway).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2015 Aug 17, 2015

the code i suggested works for me and i don't see the issue you're describing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2015 Aug 17, 2015

Well, I feel that I have wasted your time.

I tried it on another PC, and it works like a charm.

So, I need to go hunting the reason for that.

The one I was using it on is a brand new, top of the line, Lenovo X1 Carbon Thinkpad, running Windows 8.1...no joy.

Just tested on desktop running Windows 7...worked a charm.

Go figure.

I truly thank you for your time and patience.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 18, 2015 Aug 18, 2015
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines