Final stage of website (sounds) I NEED HELP

:hair: :hair: :hair:

ok basically im all done now the music problem kicks in gear

i have 7 songs

this is the first thing i have on my timeline


mySound1 = new Sound();
mySound2 = new Sound();
mySound3 = new Sound();
mySound4 = new Sound();
mySound5 = new Sound();
mySound6 = new Sound();
mySound7 = new Sound();

this is for what i have for the buttons


on(press) {
if (playing!=true) {
if (playing=true); 
soundIsLoaded=1
mySoundObject1=new Sound();
mySoundObject1.setVolume(55);
mySoundObject1.loadSound("1.mp3",true) //streaming
}
_root.mySoundObject1.onSoundComplete=function() 
{playing=false;}
}

now i have the stop button , this is my problem its not stopping the songs!! what is wrong???


on(press) {
if (playing==true) {
playing=false;

mySound1.stop()
mySound2.stop()
mySound3.stop()
mySound4.stop()
mySound5.stop()
mySound6.stop()
mySound7.stop()
}
}

please someone help me or show me another way to do it where i just click on the numbers and the music stop playing!
i have the music buttons all in a movieclip

here is the .fla

I dont know if mySound1.stop(); will even work, but I guess it does. The problem is that the two buttons aren’t using the same variable. Instead, they define their own variable. You have to put [COLOR=BLUE]playing[/COLOR] in _root, so they both use the same variable.

Just replace every [COLOR=BLUE]playing[/COLOR] by [COLOR=BLUE]_root.playing[/COLOR].

There’s something I don’t get about your code. This doesn’t make sense, does it ? It’s like saying: “If playing is true.” without a “then do” part.

[AS]
if (playing=true);
[/AS]

Let’s load the sound externally to keep your file size down.

Frame 1:

[AS]
sound1 = new Sound();
sound1.loadSound(“sound1.mp3”,true);
sound1.start(0,999);
[/AS]

Breaking down the code:

sound1 is declared as our first sound object.
loadSound simply loads the external sound(make sure its in same directory as .swf)
true declares that we are streaming the sound so the user does nto have to wait for it to download.
last line means load the sound on level 1 and loop it 999 times.

to stop your sound simply add this to the button in which you would like the sound to stop

[AS]
on(release){
sound1.stop;
}
[/AS]

to add more sound just follow the steps. to disbale sounds you can change your code to something like this:

[AS]
on(release){
if(!sound1 = true){
sound1.loadSound(“sound1.mp3”,true);
sound1.start(0,999);
}
playing = true;
}
[/AS]

I don’t have flash in fron tof me so my code may be a little off. I wil recheck it when I get home.

didnt work. _root.playing

is there another way i can make it work??

Yeah … use stopAllSounds(); Kinda drastic, but works.

checked both , still not working

if you follow mine it will work

[AS]
on(release){
yoursoundobjvaraible.stop();
}
[/AS]

Ok, this is weird, stopAllSounds(); should definitely work. Please post the exact code you’re using, with the stopAllSounds(); try.

sorry i gave yoru soem wrong code. make sure
[AS]
sound1.stop();
[/AS]

not
[AS]
sound1.stop;
[/AS]

sry

we are posting fast arent we?? haha i stopAllSounds() does work.

now my question is. how can implement that into the 1 234567 buttons where it STOPS the music playing then loads the desired music?

would



on(press) {
stopAllSounds();
if (playing!=true) {
if (playing=true); 
soundIsLoaded=1
mySoundObject1=new Sound();
mySoundObject1.setVolume(55);
mySoundObject1.loadSound("1.mp3",true) //streaming
}
_root.mySoundObject1.onSoundComplete=function() 
{playing=false;}
}

work??

digital i have to add the _root. code infront of your stop code the code from before also needs _root !! hehe wow what a brain buster.

Ok now here is my question lets say if i wanted to eliminate the STOP button and make it when you click on the button it stops all the other sounds and then it plays its sound

or it checks if the other songs are playing and if they are itll stop it and then play the song from the button clicked

ok so do this
[AS]
on(release){
sound2.stop();
sound3.loadsound(blahblahblah.mp3,true);
}
[/AS]

and omg are we posting fast :slight_smile:

its cuz we are in the same timezone and im in miami tho ehhehe

did it work? there is no need to use stopAllSounds(); each button could just stop ther sounds buy simply saying
[AS]
soundx.stop();
[/AS]

very simple.

ok so what will the final code look like??

lol ok …

[AS]
x = new Sound();
y = new Sound();
[/AS]

button 1:
[AS]
on(release){
y.stop();
x.loadSound(“mp3”,true);
x.start(0,999);
}
[/AS]

button 2:
[AS]
on(release){
x.stop();
y.loadSound(“mp3”,true);
y.start(0,999);
}
[/AS]

That will tell button 1 to stop sound y and play sound x, and vice versa. Get that to work then we will tell the buttons if the soudn id already playing, do not start it again.

btw i leave work in 10 minutes, ill be home by 4:00, if you need more help ill be happy to do so, also if you really get stuck post your .fla and ill take a look when i get home.

i just posted yer whole code and nothing worked!!

hers the.fla

omg ok ill take a look :slight_smile: