FORUMS: list search recent posts

How to stop a sound from one movie but keep buttons sound on?

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Andy Schwarcz
How to stop a sound from one movie but keep buttons sound on?
on Jun 3, 2009 at 11:00:30 pm

I am extremely brand spanking new to Flash and action script. Wanted to develop a quick website for myself using Flash and a tutorial I got. I basically got it running except a couple of minor details. Here's my main problem. I essentially have 5 pages. On one of the pages (the Our Work page) is a video that plays when you go to that page. If you click away from that page the audio from that video keeps playing while you are not on that Our Work page, which I don't want. I put this command in SoundMixer.stopAll();
It does the job of stopping the audio from that video when you click away but now whenever you click on any button on any page it cuts off the sound fx of the button click. Is there a command that lets me not stop ALL and just stop that particular audio from that video? Below is my code. It's all on the first frame. Thanks in advance!


stop();

//handle events for buttons...
About.addEventListener(MouseEvent.CLICK, clickSection);
JustAsk.addEventListener(MouseEvent.CLICK, clickSection);
OurWork.addEventListener(MouseEvent.CLICK, clickSection);
Contact.addEventListener(MouseEvent.CLICK, clickSection);
Services.addEventListener(MouseEvent.CLICK, clickSection);



function clickSection(evtObj:MouseEvent){
//trace shows what's happening in output window
trace ("The "+evtObj.target.name+" button was clicked!")
//stop audio from video
SoundMixer.stopAll();


//go to the section clicked on...
gotoAndStop(evtObj.target.name);
}



Return to posts index

demetri tashie
Re: How to stop a sound from one movie but keep buttons sound on?
on Jun 4, 2009 at 5:00:27 pm

hi andy-

there are a few ways you could acheive this - but how is your sound attached to the buttons ? is it embedded in the button's Over state ?

i scripted your buttons ( i would use MovieClip symbols as buttons, rather than Button Symbols) to play a sound from the library when clicked. i separated this function from the navigation function, so each click will kill all sounds, then navigate to correct frame and then execute the code to always play the soundFX.
i added a commented out "if" statement that you could play around with also, to just kill the video sound only when navigating away from the "OurWork" frame, as it is presumably not necessary for the other frames. anyway, this should help, and give you the idea. let us know how it goes.

here is your script, whcih i modified to reflect that,as well as to play the embedded sound for the button clicks ( i have tested all this code ) :

stop();

//handle events for buttons...
About.addEventListener(MouseEvent.CLICK, clickSection);
JustAsk.addEventListener(MouseEvent.CLICK, clickSection);
OurWork.addEventListener(MouseEvent.CLICK, clickSection);
Contact.addEventListener(MouseEvent.CLICK, clickSection);
Services.addEventListener(MouseEvent.CLICK, clickSection);


About.addEventListener(MouseEvent.CLICK, soundFX);
JustAsk.addEventListener(MouseEvent.CLICK, soundFX);
OurWork.addEventListener(MouseEvent.CLICK, soundFX);
Contact.addEventListener(MouseEvent.CLICK, soundFX);
Services.addEventListener(MouseEvent.CLICK, soundFX);

var mySound:CustomSoundClass = new CustomSoundClass();

function clickSection(evtObj:MouseEvent){
//trace shows what's happening in output window
trace ("The "+evtObj.target.name+" button was clicked!")
//stop audio from video
// or you could use the following "if" statement to target just this frame
//if(currentLabel=="OurWork") { SoundMixer.stopAll()}
//go to the section clicked on...
SoundMixer.stopAll();
gotoAndStop(evtObj.target.name);
}



function soundFX(evt:MouseEvent):void{
mySound.play();
}




Return to posts index

Andy Schwarcz
Re: How to stop a sound from one movie but keep buttons sound on?
on Jun 5, 2009 at 2:05:14 am

Wow! Thanks so much. Unfortunately, when I copied and pasted the code in, it didn't work. To answer your question, I made Button Symbols and embedded the sounds in the Over and Down states. Like I said in my previous post, I'm extremely new to this so bare with me. Is it ok that I still have the buttons as Button Symbols or did I need to change them to Movie Clips...and if so, how...just change that in the Properties panel?
Below are the 2 Compiler Errors I received when I ran your code. Both of the errors stemmed from that line 17.

Location
Scene 1, Layer 'Actions/Labels', Frame 1, Line 17
Description
1046: Type was not found or was not a compile-time constant: CustomSoundClass.
Source
var mySound:CustomSoundClass=new CustomSoundClass()

Location
Scene 1, Layer 'Actions/Labels', Frame 1, Line 17
Description
1180: Call to a possibly undefined method CustomSoundClass.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]