Change volume with mouse wheel
Hey. I have script:
stage.addEventListener(MouseEvent.MOUSE_WHEEL, garsas);
var volumeAdjust:SoundTransform = new SoundTransform();
volumeAdjust.volume = 1;
function garsas(event:MouseEvent) {
var delta:int = -event.delta;
if(delta < 0){
volUp();
}
if (delta > 0){
volDwn();
}
}
{
volumeAdjust.volume += 0.05;
if(volumeAdjust.volume > 1)
{
volumeAdjust.volume = 1;
}
soundTransform = volumeAdjust;
}
function volDwn():void
{
volumeAdjust.volume -= 0.05;
if(volumeAdjust.volume < 0)
{
volumeAdjust.volume = 0;
}
soundTransform = volumeAdjust;
}
This is script is working for me just one time. I mean if music starts play in the first frame its working. bet then a new sound starts the wolume is max and this script is not working any more. And i cant understad why? Can any one help ?
