all groups > flash actionscript > december 2005 >
You're in the

flash actionscript

group:

Random sounds


Re: Random sounds res7cxbi NO[at]SPAM verizon.net
12/17/2005 3:37:07 PM
flash actionscript:
Simply use Math.random()

If you want to make sure that a DIFFERENT sound is played the next time
guaranteed, you can use SharedObject.
Here's an example tested under Flash MX:

mySO = sharedobject.getLocal("someSOName");
//If first time visit
if(mySO.data.whatPlayedLastVisit = null) {
//do something like play default sound
} else {
//play random sound but use this line to access what played
played = mySO.data.whatPlayedLastVisit;
//play something
mySO.data.whatPlayedLastVisit = whatJustPlayed;
mySO.flush();
}
Random sounds eminthepooh
12/17/2005 7:08:21 PM
I have 4 sound bits in my library and im tryin to make it so that everytime the
flash loads, a random one of the sounds will play, end, and stop. Then if i
reload the flash, i get a different random sound bit. Anyone know how the code
for that would be?
Re: Random sounds res7cxbi NO[at]SPAM verizon.net
12/18/2005 5:33:29 PM
Sorry, typed it in all wrong

mySO = sharedobject.getLocal("someSOName");
//If first time visit
if(mySO.data.whatPlayedLastVisit == null) {
//do something like play default sound
} else {
//play random sound but use this line to access what played
played = mySO.data.whatPlayedLastVisit;
//play something
//Then store what just played into mySo
mySO.data.whatPlayedLastVisit = whatJustPlayed;
//NOW write it to mySo
mySO.flush();
}
AddThis Social Bookmark Button