1 Reply Latest reply on Jun 14, 2006 10:07 AM by kglad

    Volume Slider Help Needed

    Siriun
      I have a banner with a background sound that reloads every time a visitor goes to a new page. The sound level is controlled by a volume slider that I built using this tutorial and now I want to save the position of the slider as a cookie. I think I need to use a SharedObject but am struggling to use it properly! This is where I have got to:

      ActionScript:
      //attach and play sound
      mySound = new Sound(this);
      mySound.attachSound("stream");
      mySound.start(0,999);
      mySound.setVolume(50);//stops sound 'clipping' on start

      var mySO:SharedObject = SharedObject.getLocal("mySoundCookie");

      //uncomment the next 2 lines when testing
      //delete mySO.data.myPoint;
      //mySO.flush();

      //check for existing data
      if (mySO.data.myPoint != undefined || !mySO.data.myPoint){
      //set starting volume
      slider.bar._y = -50;
      }
      //set volume of sound to y position
      slider.bar.onEnterFrame = function() {
      mySound.setVolume(0-this._y);
      }

      //constrain dragging to the slider
      slider.bar.onPress = function() {
      startDrag(this, false, this._x, -65, this._x, 0);
      }
      slider.bar.onRelease = slider.bar.onReleaseOutside = function() {
      stopDrag();
      }

      //store position of bar as a variable
      var myPoint = new Object();
      myPoint = slider.bar._y;

      trace(myPoint);

      //create sound cookie
      mySO = SharedObject.getLocal("mySoundCookie");
      mySO.data.obj = myPoint;
      mySO.flush();


      I have tried following SharedObject tutorials and the Flash Help files but am failing to grasp how to use them, so would be very grateful if someone could help me fix this script.

      Many thanks.