Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start - Stop Audio Button 1

Status
Not open for further replies.

alokwww

Technical User
Dec 25, 2002
86
I have a sound I'm playing from frame one. I want to create a button that if the sound is playing will stop the sound and if the sound is stopped will start the sound. The actions I have on frame one are:


firstSound=new Sound();
firstSound.attachSound("firstSound01");

{
_root.firstSound.start(0,999);
playing=true
}


The actions I have on the button are:


on (press) {
if (playing=true) {
_root.firstSound.stop("firstSound01")
playing=false
}

if (playing=false) {
_root.firstSound.start("firstSound01")
playing=true
}
}


This still doesnt work. Can anyone tell me what I'm doing wrong.
Also, is there a way to change the button (symbol name is ButtonMute) color to blue if the sound is stopped and to yellow if the sound is started?

Thanks
-Alok
 
Check out...


Everything you ever wanted to know about sound but were afraid to ask! Regards,

oldman3.gif
 
lol, it just so happens that that exact page was posted on flashkit and thats where I got my information for the code. Unfortunately, it doesnt say how to use the same button to start and stop a sound. It uses two seperate buttons, one to stop, and one to start. I'm trying to integrate both into one. Anyone have hints on doing that?
Thanks
-Alok
 
If you use the right syntax, maybe, just maybe will it work:

firstSound=new Sound(this);
firstSound.attachSound("firstSound01");
_root.firstSound.start(0,999);
playing=true;

The actions I have on the button are:

on (press) {
if (playing==true) {
_root.firstSound.stop("firstSound01");
playing=false;
}

if (playing==false) {
_root.firstSound.start("firstSound01");
playing=true;
}
}
Regards,

oldman3.gif
 
Hmm, I tryed this and what seems to happen is when the button is pressed the sound stops but right away starts again. Any suggestions?
Thanks for the quick reply
-Alok
 
How about...

on (press) {
if (playing==true) {
_root.firstSound.stop("firstSound01");
playing=false;
} else {
_root.firstSound.start("firstSound01");
playing=true;
}
}
Regards,

oldman3.gif
 
I love you all.
Thanks for the quick replys. Works perfectly now.
Thanks all!
 
If there's one action I hate, it's the "with" action.

Makes me think of NS!

Here's one for your efforts Bill! At least this time I can't blame your syntax, or for that matter, your sense of hunmour! Regards,

oldman3.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top