flash - How do I reverse my sound volume math for my volume slider? -


I am creating a video player and I have stopped a bit in the volume slider section. If the slider should be 100% in the volume of the top spot and if the slider is dragged to sound down position should be 0. Currently it is the opposite of what I want it to have a YouTube-style vertical slider, which means: (

, will sound louder drag the slider down, while pulling up it lowers.

the volume is my code below dealing with the slider.

< Pre> // sound controller set NGC ······························ soundController = new soundController (); soundContrColor = soundController.colorChip; soundContrGray = soundController. GrayCover; soundContrGray.visible = false; soundController.visible = true soundController.buttonMode = true soundController.soundSlider.addEventListener (MouseEvent.MOUSE_DOWN, sliderDown); // SoundController button mouse events ··········· public function Slaiderdaun ( event: Mausivent): void {soundController.sound Slaiderktartdrag (false, Dragbond); sound controller. SoundSliderkaddEventListener (Mausivent. Mausudg, Slaidermov); SoundController.soundSlider.addEventListener (MouseEvent.MOUSE_UP, SliderUp); SoundContrGray.visible = true; } Public Function SliderMove (Event: MouseEvent): Zero {soundContrGray.height = soundController.soundSlider.y; UserVolume = Math (((Sound ContraregEI * Sound Controls High.) / 10) - 4); // userVolume = soundContrGray.height; SetVolume (userVolume); Trace ("soundController.mouseY =" + soundController.soundSlider.y); Trace ("soundContrColor.height =" + Math.round (soundContrGray.height)); Trace ("user volume =" + user volume + "\ r"); Event.updateAfterEvent (); } Public Function SliderUp (Event: Mouse Event): Zero {lastVolPoint = soundContrGray.height; SetVolume (userVolume); Event.updateAfterEvent (); SoundController.soundSlider.stopDrag (); SoundController.soundSlider.removeEventListener (MouseEvent.MOUSE_MOVE, SlideMow); SoundController.soundSlider.removeEventListener (MouseEvent.MOUSE_UP, SliderUp); } [TRACES] When I draw all the way to the top:
  soundController.mouseY = 6 soundContrGray.height = 6 User Volume = 0  

[TRACES] When I drag all the way down:

  soundController.mouseY = 56 soundContrGray.height = 56 User Volume = 30  < / Pre> 

I believe this, where the problem is:

  userVolume = mathematics. (((SoundContrGray.y * soundContrGray.height) / 10) - 4);  

(- 4) is an offset value, when you drag all the way to stop it, it is not 0 and 4.
I need to reverse this anyhow, so the mark will swap above ... going down the userVolume = 4 and going up 30 will make it 30 for anyone in advance will do it.

Thank you that it takes a look at one! :)

I should remember something because this can not be easy, is not it?

userVolume = 30-Math.round (((soundContrGray.y * soundContrGray.height) / 10) - 4);

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -