Flash player with SharedObject
// creates a sound object
var my_snd_obj:Sound = new Sound();
// attaches the sound to teh sound object
my_snd_obj.attachSound(“my_audio”);
// sets the volume to 15 out of 100 (default is 100)
my_snd_obj.setVolume(100);
// looks for shared object
var my_so:SharedObject = SharedObject.getLocal(“userPref”);
// if it is not there it plays the audio from the start looping it 1000 times
if (my_so.data.stopped == undefined) {
my_snd_obj.start(0, 1000);
// else it stops the audio
} else {
my_snd_obj.stop();
}
// stop button, stops audio and creates shared object
stop_but.onRelease = function() {
my_so.data.stopped = 1;
my_so.flush();
my_snd_obj.stop();
};
// play button, starts audio from the start looping it 1000 times (only if it is not playing) and deletes shared object
play_but.onRelease = function() {
if (my_so.data.stopped == !undefined) {
my_snd_obj.start(0, 1000);
my_so.clear();
}
};