Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Save the value of a Boolean variable

Explorer ,
May 26, 2016 May 26, 2016

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!

TOPICS
ActionScript
942
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , May 30, 2016 May 30, 2016

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

Translate
LEGEND ,
May 26, 2016 May 26, 2016

How / where is this application implemented?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 26, 2016 May 26, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 27, 2016 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 29, 2016 May 29, 2016

Local application, the second option in case.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 30, 2016 May 30, 2016
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 26, 2016 May 26, 2016

Use the SharedObject class.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines