# Audio functions colliding, I think I need a helping hand

**URL:** <https://forum.kirupa.com/t/audio-functions-colliding-i-think-i-need-a-helping-hand/325564>\
**Category:** Uncategorized\
**Created:** [October 23, 2011, 8:11pm UTC](https://forum.kirupa.com/t/audio-functions-colliding-i-think-i-need-a-helping-hand/325564 "2011-10-23T20:11:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eyewoo](https://avatars.discourse-cdn.com/v4/letter/e/e19b73/32.png) [@eyewoo](https://forum.kirupa.com/u/eyewoo)\
**Post date:** [October 23, 2011, 8:11pm UTC](https://forum.kirupa.com/t/audio-functions-colliding-i-think-i-need-a-helping-hand/325564/1 "2011-10-23T20:11:00Z")

</div>

(CS3 - AS2)

I have an swf playing an external flv. On mouseOver on the video the audio should fade up, and on mouseOut the audio should fade out. This works fine. However. I have a pause button (playpause) that also pops up on mouseOver, and disappears on MouseOut and what actually happens when you mouseOver playpause or mouseOut the video is that the audio fades out and then pops back up 100 when reaching 0. I get there are two volume controls working against each other in that situation, but I am not sure how to solve it. the volume needs to be maintained at 100 when mouseOver on playpause. I would be really glad if someone could help me solve this.

```auto
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.setBufferTime(5);
theVideo.attachVideo(ns);
ns.play("hxxp://url/folder/video.flv");

ns.onStatus = function(info) {
if(info.code == "NetStream.Play.Stop") {
ns.seek(0);
}
};

btn.useHandCursor = false;
playpause._alpha = 0;

var snd:Sound = new Sound(this);
snd.attachSound(theVideo);
snd.setVolume(0);
var soundStarted:Boolean = true;
var lastPosition:Number = 0;
var id:Number;

function soundOn(){
var v:Number = snd.getVolume();
snd.setVolume(100);
clickToggle=true;
};

function soundOff(){
var v:Number = snd.getVolume();
snd.setVolume(Math.abs(v-100));
clickToggle=false
};

function pauseMe() {
ns.pause();
if(playpause._currentframe==1) {
playpause.gotoAndStop(2);
} else {
playpause.gotoAndStop(1);
}
}

this.onMouseMove = function() {
if(playpause.hitTest(this._xmouse, this._ymouse)) {
playpause._alpha = 100;
soundOn();
}
}

playpause.onRelease = function() {
pauseMe();
};

btn.onRollOver = fadeUp;
function fadeUp():Void {
if (id) {
clearInterval(id);
}
snd.start(lastPosition);
var v = snd.getVolume();
id = setInterval(fadeIn, 10);
function fadeIn():Void {
snd.setVolume(v++);
if (v>=100) {
clearInterval(id);
}
}
playpause._alpha = 100;
clickToggle=true;
}

btn.onRollOut = fadeOut;
function fadeOut():Void {
if (id) {
clearInterval(id);
}
var v = snd.getVolume();
id = setInterval(fadeOut, 5);
function fadeOut():Void {
snd.setVolume(v--);
if (v<=0) {
clearInterval(id);
snd.setVolume(Math.abs(v-100));
lastPosition = Math.round(snd.position/1000);
}
}
playpause._alpha = 0;
clickToggle=false
}

```
