Sound on/off toggle

Could someone tell me why this doesn’t work?
I’m combining a couple different ideas from Kirupa tutorials and Flashkit movies.

Basically, its just two buttons (on, off). One in frame 1 and one in frame two of the timeline. I’ve attached AS to frame 1 to load and start the music. I’ve attached AS to each button to “supposedly” control its “onrelease” action.

The load and start sound works fine, but the buttons don’t seem to have any effect.

Here’s the fla. I used a Buffy The Vampire Killer sound clip to keep the fla small for sake of file transfer.

the code in the buttons should be in the timeline. not in the button actions :-
just don’t forget to put the instance names in both buttons :wink:

and you don’t need to enable/disable the buttons … since each button is on different frame it’s useless :slight_smile:

// frame 1
bgSound = new Sound(this);
bgSound.start(0, 99);
soundon.onRelease = function() {
// frame 2
soundoff.onRelease = function() {

[size=1]ps. it’s buffy the vampire slayer!!! :P[/size]


made the changes.
still works like it did.
sound plays in a loop, button doesn’t do anything.
I tried it from both Control/Test Movie and published and ran outside of FlashMX.

ps. You’re right it is BTVS. My bad. Its the SMG show. I’ll miss it when she leaves and the show goes away.
Years ago there was a show called NightStalker I believe where a guy chased Vampires. Used to watch that one.

it works. i tested it before posting :wink:

make sure you have soundon and soundoff respectively in the instance name of your buttons.

Well, Duh.

That’s like not plugging in your monitor and wondering why your computer doesn’t work.

That did the trick.

I did find another way to do it that works in the meantime.
Yours would still be superior, because this requires AS on the buttons.

Here it is:

Given the same two frame MC with one button in each frame.

On button1 we put:

on (release) {

On button2 we put:

on (release) {

On Frame1 put:

bgSound = new Sound(this);
bgSound.start(0, 99);

On Frame2 put:


Finally, import the sound to the library and drag an
instance of it onto the stage of Frame1.

That’s it.