Random sounds...
Karl Becker
karl at karlbecker.com
Mon Sep 30 13:45:08 EDT 2002
On Monday, September 30, 2002, at 08:22 PM, kjphyland at australia.edu
wrote:
> However, when I tested it on the pre-schoolers (talk about a TOUGH
> crowd!)
> they wanted to hear it again before proceeding..
>
> my current (enormous) code is
>
> play (any line of card field "SoundList")
>
> my question...if I make a button called say "REPEAT?" how do I get
> Metacard
> to replay the directly previous sound from the "SoundList" field?
There would be a number of methods, but here's one idea...
Script line #1:
global theRandomNumber
Here we're declaring a global variable - what this does is lets us use
this variable, and the value that's stored in it, in every script,
anywhere, whether it's another button, field, card, or stack.
Script line #2:
put random( the number of lines of card field "SoundList" ) into
theRandomNumber
This puts a random number from 1 to the number of lines of the field
"SoundList" into the variable named theRandomNumber.
Script line #3:
play (line theRandomNumber of card field "SoundList")
Very similar to before.
Now, make a new button, maybe named "Repeat", and put in these two
lines of script:
global theRandomNumber
play (line theRandomNumber of card field "SoundList")
Here we're using carbon copies of our old script, but just excluding
the line of script that got a new random sound.
Hopefully this was explained well enough. Good luck with MetaCard,
glad to have you on board!
P.S. You can get rid of that ugly "card" word by turning off
hcAddressing as described in a previous post. You can simply delete
the word card from every line of script above.
--
Go Bison!
http://www.karlbecker.com
More information about the metacard
mailing list