PDA

View Full Version : Switching sounds during a movie


ImDumb
12-09-2001, 04:47 AM
ok, there is probably a really simple solution to my problem, but i JUST started learning Flash 5.0 yesterday and i cant figure something out......

i have a movie where there is background music playing, and i have a button to toggle it on/off... that part works fine...

i decided i wanted the option to toggle between two different background music samples, so i tried to use a boolean variable to determine which to play, and have a button to toggle the boolean function, but i cant get it to work.

on the first frame i have an action script like this:
SndPlay = new Boolean ( false );

i also have another action script which corresponds to the first sample:
mySound = new Sound();
mySound.attachSound("librarySound");

and one the corresponds to the second sound:
mySound2 = new Sound();
mySound2.attachSound("librarySound2");

on the "start music" button, which comes in around frame 110 there's this:
on (release) {
if (SndPlay = true) {
mySound.start(0, 100);
}
else {
mySound2.start(0, 100);
}
}

and on the toggle button i have:
on (release) {
if (SndPlay = true) {
SndPlay = false;
}
else {
SndPlay = true;
}
}


and it wont work... every time i click the "play" button, it plays mySound2... ..... i dont know if its just because i'm not doing the right things with the code or if its more complex than that.... any help would be greatly appreciated... thank you

Billy T
12-09-2001, 05:05 AM
not sure if there are other things wrong as well but your if statements should contain the == operator

eg

if (SndPlay == true) {
mySound.start(0, 100);
}


cheers

ImDumb
12-09-2001, 05:26 AM
hey, thanks a lot... i tried it out and it works... much appreciated...