Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / General Flash Topics / July 2008



Tip: Looking for answers? Try searching our database.

How to stop sound ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rocio08 - 10 Jul 2008 19:20 GMT
Hi,

I inluded a sound file in a keyframe in the timeline of my website .fla file.
When I test my website, the sounds plays all the time unless I press the stop
sound button manually, I am ok with that. Within my website I have links to
other websites or files that have their own sound, or voice over. As you can
imagine it sounds "messy" when any link is clicked on because I hear my sound
plus the sounds of the sites opened.
My question is, what AS2 code should I include to have my sound stop once the
user clicks any link?
Is it possible also, to have my sound  turned back on, once the user closes
the other link?

I have the links written in the AS of movie clips. For example:

ACTION MOVIE-CLIP

on (rollOver) {
    this.gotoAndPlay("s1");
}
on (releaseOutside, rollOut) {
    this.gotoAndPlay(_totalframes-_currentframe);
}
on (release) {
    getURL("http://www.dreams.com","_blank");
}

I appreciate any help provided on this matter.

Rocio
Shan-Dysigns - 11 Jul 2008 02:28 GMT
From what you typed, it appears you are placing a sound clip inside a movie
clip and trying to control the sound by controlling the play head for that
movie clip. This method doesn't allow much control over your sound. You should
use linkage id's to control your sound.

Import a sound file into the library, right-click the sound file, go to
linkage, give the sound clip an identifier name, click to export for action
script and first frame. Then, to initially start a sound clip, put this code in
a frame:

var soundClip:Sound=new Sound(this);
soundClip.attachSound("idName");
soundClip.start();

soundClip is a random variable name
idName is the linkage name you gave the file

Then, when you click another button and want to stop the current sound, you
can place this code on the button or movie clip:

on(press) {
soundClip.stop();
}

If you set up the soundClip sound on the main time line, and have this button
nested in other movie clips, you will have to reference the correct timeline by
_root.soundClip.stop(); Of course, you can always use:

on(press) {
stopAllSounds();
}

to stop all sounds currently playing (at least in this case). Now, in order to
begin a new sound when you click a new button, you would use similar code:

on(press) {
// soundClip.stop();
// _root.soundClip.stop();
// stopAllSounds();
var sound2:Sound=new Sound(this);
sound2.attachSound("idName");
sound2.start();
}

The above code, you have three choices to stop previous sounds. Of course, you
would have to import your second sound file into the library, (follow steps as
in the first sound clip)... make sure you give it a different linkage name
"idName".

Unless I read your post wrong, all the things I mentioned should help you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.