Trouble with sound and a repeat loop
Posted: Tue Jun 14, 2011 8:55 am
Hi,
I'm having a heck of a time working with playing basic sounds in a simple (at this point) 2 card stack. My goal is to move to a card, and play a sound file that asks the user to click on an object. The sound file will repeat every five seconds until the user clicks the object. If they don't get it the first time, I show an image of a finger touching the object so they get a visual clue (that also repeats).
Here's my code:
The problem is that once a sound file plays, execution stops. I've figured this out because if I comment out the "play" commands:
it happily repeats the hide / show image forever (well, OK, I haven't tested it for that long).
The global variable "touched" gets set to true by the button on the graphic that they need to touch.
Any thoughts, comments, etc. are welcome. With humble thanks in advance, Doug
I'm having a heck of a time working with playing basic sounds in a simple (at this point) 2 card stack. My goal is to move to a card, and play a sound file that asks the user to click on an object. The sound file will repeat every five seconds until the user clicks the object. If they don't get it the first time, I show an image of a finger touching the object so they get a visual clue (that also repeats).

Here's my code:
Code: Select all
on opencard
wait 1 second
play (specialfolderpath("engine") & "/sounds/" & thelanguage & "thesoundfile.mp3") with messages
repeat while touched = "false"
wait 5 seconds with messages
play (specialfolderpath("engine") & "/sounds/" & thelanguage & "thesoundfile.mp3") with messages
show image "touching"
wait 1 second
hide image "touching"
end repeat
end opencard
Code: Select all
repeat while touched = "false"
wait 5 seconds with messages
-- play (specialfolderpath("engine") & "/sounds/" & thelanguage & "thesoundfile.mp3") with messages
show image "touching"
wait 1 second
hide image "touching"
end repeat
The global variable "touched" gets set to true by the button on the graphic that they need to touch.
Any thoughts, comments, etc. are welcome. With humble thanks in advance, Doug