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!

Srtat stop sound 1

Status
Not open for further replies.

lashwarj

IS-IT--Management
Nov 1, 2000
1,067
US
Why can i not get this to work, it plays the music but does not stop it. I am using Flash MX



on (press) {
set (counter, counter = couter + 1);
if (counter >=1)
song = new Sound();
song.attachSound("Tonic");
song.start("Tonic");
_root.speaker.play();
if (counter < 1)
song.stop(&quot;Tonic&quot;);
_root.speaker.stop();
}
 
What's this line supposed to do?

set (counter, counter = couter + 1);

Increase counter by 1?
If so, this would be easier:

counter +=1;

Is counter ever smaller than 1?
Which would explain why &quot;if (counter < 1)&quot; is never true, and thus why the music never stops.
Use a trace action, to trace the value of counter!

You should ALLWAYS add [b}this[/b] to your soundObject definitions, it will keep yo out of further troubles!
...
song = new Sound([b}this[/b]);
song.attachSound(&quot;Tonic&quot;);
...

Lastly check this great tutorial:



Regards,

oldman3.gif
 
Sorry messed up my tags in the above post!

What's this line supposed to do?

set (counter, counter = couter + 1);

Increase counter by 1?
If so, this would be easier:

counter +=1;

Is counter ever smaller than 1?
Which would explain why &quot;if (counter < 1)&quot; is never true, and thus why the music never stops.
Use a trace action, to trace the value of counter!

You should ALLWAYS add this to your soundObject definitions, it will keep yo out of further troubles!
...
song = new Sound(this);
song.attachSound(&quot;Tonic&quot;);
...

Lastly check this great tutorial:

Regards,

oldman3.gif
 
Still wont work
on (press) {
set (counter, counter +=1)
{if (counter <=1)
song = new Sound()
song.attachSound(&quot;Tonic&quot;)
song.start(&quot;Tonic&quot;)
_root.speaker.play()}
if(counter < 1)
song.stop(&quot;Tonic&quot;);
_root.speaker.stop();
}
 
The set (counter, counter = couter + 1);
is to create a variable counter that is the user clicks it once the nect time it will turn it off, actually if i can make it so even clicks turns off and odd clicks turn on
 
Took a different approach thank you guys I got it

on (press) {
music = new Sound(this);
music.attachSound(&quot;tonic&quot;);
if (playing!=True) {
_root.music.start(0,999);
playing=true; }
else if (playing = True) {
_root.music.stop(&quot;tonic&quot;)}}
 
Okay, oldnewbie definitely deserves a star for at least is patience. Yoink! frozenpeas
 
Patience and the fact (a coincidence?) that this new approach is clearly described in the link I posted! Regards,

oldman3.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top