SharedObject - newbie needs help!

This seems like a fairly easy thing to fix but I can’t figure it out…

I’d like to have just one button component in my movie, where you can click it on and off. Also, I’d like it to save a SharedObject so that if the user for example clicks the button to off, the next time they load the movie it will remember to not play the music.

It seems to be working alright, but if the button is set to “on” and then I reload the movie and I click the button to turn the music off, it does not turn it off on the first click. I have to click it TWICE… Not sure why it’s doing that. If I click the button to “off” and then reload it, it works fine when I click the button ONCE to “on”. Here’s the code, I also have a link to the the files.

Any help would be much appreciated!

var so:SharedObject = SharedObject.getLocal(“settings”);
var music:Sound = new Sound(new URLRequest(“myMusic.mp3”));
var channel:SoundChannel = new SoundChannel();

music.addEventListener(Event.COMPLETE, musicLoaded);
btn.addEventListener(MouseEvent.CLICK, playSound);

function musicLoaded(e:Event):void {
//check if cookie is set to off; if not, play sound

if ( =="off"){
    btn.label = "| off";
    statustxt.text ="stopped";
    btn.label = "| on";
    channel =
    statustxt.text ="playing";


function playSound(e:MouseEvent) {
btn.label = “| on”;
channel =;
//set cookie to on = “on”;
statustxt.text =“playing”;
btn.label = “| off”;
//set cookie here to off = “off”;
statustxt.text =“stopped”;