PDA

View Full Version : switching buttons?


MercuryLime
07-04-2005, 12:55 PM
On my new website, I have music looping in the background, and a button that says 'Mute!' that stops the music when you click on it with a stopAllSounds() action. What I want is to have the 'Mute!' button turn into a 'Play!' button automatically when you press it and the music stops, so that when you press it again, it starts playing the music again. But.. how do i do that? I can't remove the old button.. does setting the alpha to 0 make the hitArea stop working? And how will i get the new button there?

Your favorite poster,
Skywire :)

bactac
07-04-2005, 01:21 PM
its better to do a MC with 2 frames, each with one button. 1st button in the 1st frame that have the sound have the action to go to the other frame that have the stopAllSounds() have a button that goes back to the first frame.

tatorhead
07-04-2005, 08:54 PM
this man speaks the truth

Lui
07-05-2005, 12:47 AM
its better to do a MC with 2 frames, each with one button. 1st button in the 1st frame that have the sound have the action to go to the other frame that have the stopAllSounds() have a button that goes back to the first frame.
just gonna make it clearer,

Its better to do an MC with 2 frames, each with one button, the button in the 1st frame will have the stopAllSound(); code and the button on the 2nd frame will have the unmute code.

in a more more more easier explanation for all of the people out ther who still is searching for this and hasnt found it,

make a MC, in the MC make 2 keyframes,in the first one make a button that says "Mute!" and add this code in:

on (release){
stopAllSounds();
this.gotoandstop(2);
}


next make another button on the second keyframe with "Unmute or Play!" on it and add this code in

on (release){
playAllSounds();//im not sure with this "playallsounds();"code thing..
this.gotoandstop(1);
}

tatorhead
07-05-2005, 12:51 AM
yeah or just make the music play in the first frame and send the second button back.

you really said the exact same thing with a lot more words

Lui
07-05-2005, 01:21 AM
lol, just for more explanation :D

Swas
07-05-2005, 01:36 AM
just to annoy im gonna type up a pointlessly complicated method :D

make a dynamic text box (inside a movieclip) var name pM
movieClip instance name: but_mc.

on the main frame type:


play = true
onEnterFrame = function (){

if (play == true){
//attachSound code;
but_mc.pM = "Mute";
} else {
stopAllSounds ();
but_mc.pM = "Play";
}

but_mc.onPress = function (){
play = !play
}

This way you lower the size of your file (by a bout a kb :P) and make actionscript do more work

eatmorchikin6464
07-05-2005, 01:46 AM
just gonna make it clearer,

Its better to do an MC with 2 frames, each with one button, the button in the 1st frame will have the stopAllSound(); code and the button on the 2nd frame will have the unmute code.

in a more more more easier explanation for all of the people out ther who still is searching for this and hasnt found it,

make a MC, in the MC make 2 keyframes,in the first one make a button that says "Mute!" and add this code in:

on (release){
stopAllSounds();
this.gotoandstop(2);
}


next make another button on the second keyframe with "Unmute or Play!" on it and add this code in

on (release){
playAllSounds();//im not sure with this "playallsounds();"code thing..
this.gotoandstop(1);
}


Well, ya might want correct syntax...just a thought.

Lui
07-05-2005, 01:50 AM
there's syntax error? *goes and check*

Swas
07-05-2005, 02:49 AM
there's syntax error? *goes and check*

yup... gotoAndStop not gotoandstop

thought you were talking to me EMC, i was offended (though there probably is errors in the BS i just typed)

eatmorchikin6464
07-05-2005, 08:33 AM
Well, I can't find any in your's Swas.

Also, Lui, it's _this not this.

MercuryLime
07-05-2005, 03:10 PM
Actually, it was too much for me to handle. I gave up on it.

Nah, I just thought it was easier this way.

Swas
07-06-2005, 03:55 AM
were you talking about my method or lui's, i only posted mine because i was bored you should probably ignore it :p