[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

How to keep sound off after page change?

http://www.entheosweb.com/Flash/flash_sound_button.asp

Hi!

I found the page above on the Net and it has a nice simple way to make a sound on/off button, which I have used on my Flash file at:

http://www.tallpinedesign.com/clients/creativeposse/v2/indexTEST2.html

The trouble is, when the user selects "Sound Off" and then changes pages and later returns to the (Flash) page, the sound defaults back to "on". How can one keep the "off" state in that case?

Max
0
tallmax
Asked:
tallmax
  • 2
2 Solutions
 
MontoyaProcess Improvement MgrCommented:
You can use SharedObjects to basically create a type of cookie on the user's machine. This "cookie" will keep the value of a variable, which you will check everytime the user visits the page.

for example:

this.onLoad = function(){
 if(soundOff==true){
      mySound.stopAllSounds();
}

}

// that's just an example that would have to be adjusted to fit your code.

0
 
MontoyaProcess Improvement MgrCommented:
This link has some general information about this, and could help you with your solution. If you're still having trouble, then please let me know and I'll be happy to help you further:

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20765871.html?query=shared+objects&topics=116


0
 
tallmaxAuthor Commented:
Hi Iammontoya!

I grabbed your code and made a new layer on the main timeline (Scene 1) and added that code as an action script:

this.onLoad = function(){
 if(soundOff = "true"){
      mySound.stopAllSounds();
}

}


I'm no expert at actionscripting (sorry). The sound I have is on a layer with an instance name "music". Where in the example above would I change the code to fit my particulars? Can you highlight the sections?

Your help is genuinely appreciated. Thanks.
0
 
GuicCommented:
Hi,

You have to save your state in a cookie:
Frame 1:

var dmcCookie = SharedObject.getLocal("cookietest","/");
if(dmcCookie.data.stateSound == undefined || dmcCookie.data.stateSound == "ON"){
                // default value is ON
      dmcCookie.data.stateSound = "ON";
                startTheSound(); // function that start the sound
} else {
               // do nothing
}


Your clic on the button SwitchSound:
on (release) {
      if(dmcCookie.data.stateSound == "ON"){
            dmcCookie.data.stateSound = "OFF";
            dmcCookie.flush()
                                stopTheSound(); // function that stop the sound
      }else{
            dmcCookie.data.stateSound = "ON";
            dmcCookie.flush()
                                startTheSound(); // function that start the sound
      }
}


Regards
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now