Skip to main content
Inspiring
May 26, 2016
Answered

Save the value of a Boolean variable

  • May 26, 2016
  • 2 replies
  • 1004 views

How can I be saving the value of a Boolean variable, so that when I open the file, it can be with the settings in which I left?

I created the variable to the top of the frame:

var audio:Boolean = true;

And I added the conditions for the buttons:

if(audio == true) {

    Sound.play();

  }

But every time I have to open the application preference is reset to true, wanted to leave with that preference be saved in the case of boolean, true (on) or false (off).

can anybody help me? Please.

Thanks in advance!

This topic has been closed for replies.
Correct answer dmennenoh

Local application, the second option in case.


A sharedObject is still appropriate for a local application. The only reason to use anything else would be storage size requirements.

2 replies

Legend
May 27, 2016

Use the SharedObject class.

Ned Murphy
Legend
May 26, 2016

How / where is this application implemented?

vvvverTAuthor
Inspiring
May 27, 2016

Hello Ned!

A button created from the addEventListener...

Let's say X button:

function X (Event:MouseEvent):void

{

     if(sound == true) {

         som = false; // bool

     }

     trace("mute")

}

Is something like this could help me?

Ned Murphy
Legend
May 27, 2016

What I meant was... is this a web interface or a local application only on the user's machine?  For the web use a Shared Object.  For a local application you might want to look into utilizing a data file to store information you wish to retain