This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-04-27 12:03:11

pross67
Scratcher
Registered: 2007-05-26
Posts: 18

one button - two functions - how?

I'd like to have a sprite that plays a short music clip when you click on it, but I'd also like the same sprite to stop playing the clip.

The "when __clicked" block isn't working for me when I use an "if" block, like "if costume # = 1" then stop playing sound.

Any ideas?

Offline

 

#2 2010-04-27 12:37:33

Stickman704
Scratcher
Registered: 2009-01-31
Posts: 1000+

Re: one button - two functions - how?

pross67 wrote:

I'd like to have a sprite that plays a short music clip when you click on it, but I'd also like the same sprite to stop playing the clip.

The "when __clicked" block isn't working for me when I use an "if" block, like "if costume # = 1" then stop playing sound.

Any ideas?

It's complicated. I can't really explain.

Try creating a varible called button function.

Then
if _ clicked
If <button function = function 1>
Play sound
wait 1 second
set function to function 2
else
stop all sounds
wait 1 second
set function to function 1
_

The wait one second is to make sure it doesn't stop, play, stop, play really quickly.

Oh wait, I've just explained it  tongue 

Hope that helps.

Last edited by Stickman704 (2010-04-27 12:59:42)


Dun dun dun dun dun dun.... dun dun dun dun dun dun...  tongue

Offline

 

#3 2010-04-27 14:08:28

pross67
Scratcher
Registered: 2007-05-26
Posts: 18

Re: one button - two functions - how?

thank you! That worked.

Offline

 

#4 2010-04-27 15:44:37

Stickman704
Scratcher
Registered: 2009-01-31
Posts: 1000+

Re: one button - two functions - how?

pross67 wrote:

thank you! That worked.

Any time! You can request for this to be closed since it's resolved.


Dun dun dun dun dun dun.... dun dun dun dun dun dun...  tongue

Offline

 

Board footer