# Using AS3 SharedObject in Flash for sound

**URL:** <https://forum.kirupa.com/t/using-as3-sharedobject-in-flash-for-sound/300419>\
**Category:** flash\
**Created:** [November 20, 2009, 5:50pm UTC](https://forum.kirupa.com/t/using-as3-sharedobject-in-flash-for-sound/300419 "2009-11-20T17:50:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wuzzi2ya](https://avatars.discourse-cdn.com/v4/letter/w/e79b87/32.png) [@wuzzi2ya](https://forum.kirupa.com/u/wuzzi2ya)\
**Post date:** [November 20, 2009, 5:50pm UTC](https://forum.kirupa.com/t/using-as3-sharedobject-in-flash-for-sound/300419/1 "2009-11-20T17:50:26Z")

</div>

Need a cookie for sound to keep it from playing everytime the page is visited and or navigated away from and back to…

Okay I have moved on to this, but alas it still doesnt work… ANY feedback would help tremendously…

```auto
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userPref");

SoundOff.addEventListener(MouseEvent.CLICK, StopTheSound);
function StopTheSound(event:MouseEvent):void {
    //SoundMixer.stopAll();
    var s:SoundTransform = new SoundTransform();
    s.volume = 0;
    SoundMixer.soundTransform = s;
    if (so.data.stopped == undefined) {
        s.volume = 1;
    } else {
        s.volume = 0;
    }
}

```
