I have a site that has as almost all Flash site have music. I want to have a video commercial play and I was wondering if there is a way to make the audio stop while the video is still playing, and then turn back on when I exit the video area.
You can use Actionscript's Sound class to change the volume. For example:
s = new Sound(); s.setVolume(0);
This will mute the volume. For more info on this class, see the reference at http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary668.html
Imagine videoPlayer is the name of your video player and musicPlayer is the name of your mp3 player. You would have something like.
videoPlayer.addEventListener(MouseEvent.ROLL_OVER, videoPlayerOver);
videoPlayer.addEventListener(MouseEvent.ROLL_Out, videoPlayerOut);
function videoPlayerOver(event:MouseEvent):void{
musicPlayer.pause();
}
function videoPlayerOut(event:MouseEvent):void{
musicPlayer.resume();
}
this is just a hint. the video player pause() would pause your current soundChannel you're using in the player and store the current position in a variable, and resume() would play the soundChannel from where it left of ( the previously saved position variable )
you might want to pause the player when you press any video controls instead roll over, that was just an idea.
Welcome to stackoverflow and good luck! I think the FAQ mentions something about the difficulty of the questions posted so you might want to have a look.
With respect to nikmd23's answer, it turns out that there are two different Sound classes in ActionScript. I'm not a Flash expert, but I think that his approach only works if you're using Flash proper; I can't seem to get access to that particular Sound class in Flex. (Maybe someone else could point the way.) At any rate, if you're using Flex, you need to do something more like this:
var transform:SoundTransform = new SoundTransform(0, 0);
stream.soundTransform = transform;
See http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundTransform.html for more details.