Skip navigation
Currently Being Moderated

Problem with checkbox value and app.settings.getSetting()

Jun 30, 2012 1:28 PM

Tags: #after #effects #value #checkbox #app.settings

Hello everyone.

 

I`ve got a problem with getting saved settings for checkbox.

Saved settings doesn`t apply on checkbox value.

 

It`s strange, but it always "true".

 

So here piece of code:

 

checkMe = 11;    //any value for the first time running
 
 
if (app.settings.haveSetting("savea", "chck")) {                            
                      checkMe = app.settings.getSetting("savea", "chck");  // get saved value, else 11
                      alert("checkMe = "+checkMe)
                        }
                    if(checkMe == 11){
                        checkMe= false;   //if there is no saved settings, checkbox value will be false/ unchecked
                        alert("You run this script first time, so manual value will be 'false'")
                        }else{
                            checkMe = app.settings.getSetting("savea", "chck");     // if saved settings exist, get true or false
                        }
     alert("Yes, checkMe will = "+checkMe)        
    
    
win.checkPanel.chkOne.value = checkMe;  /// checkbox value will equal saved checkMe
 
var fff = win.checkPanel.chkOne.value;  // string for alert
 alert("aha! but checkbox value is  = " +fff+ "\n Why so?")     // here we`ve got always "true"
 
 
 
 
win.checkPanel.chkOne.onClick  = function () {
        
    var path11 = win.checkPanel.chkOne.value;  //  checkbox value to variable
    app.settings.saveSetting("savea", "chck", path11);  //saving checkbox value
    alert("Saved this value - " + app.settings.getSetting("savea", "chck"))
          }
 

 

win.checkPanel.chkOne.value is always true.

Can someone exmplain why and how to get rid of this static value?

 

 

P.S. just in case, here is full code:

 

 

function mainFun() 
{
 
 
    this.windowRef = null;
}
 
 
 
 
mainFun.prototype.run = function()
{
    
    /*----- UI -----*/
          var retval = true;
          var win = new Window("palette", "Check option", [150, 150, 460, 455]);
          this.windowRef = win;
 
 
    
          win.checkPanel = win.add("panel", [25, 150, 285, 265], "Checkbox");
          win.checkPanel.chkOne = win.checkPanel.add("checkbox", [10, 15, 125, 35], "Checkbox One");
          //win.checkPanel.chkTxtOne = win.checkPanel.add('edittext', [140, 15, 230, 35], '');
 
 
     win.quitBtn = win.add("button", [110,275,200,295], "Close");
 
 
checkMe = 11;    //any value for the first time running
 
 
if (app.settings.haveSetting("savea", "chck")) {                            
                      checkMe = app.settings.getSetting("savea", "chck");  // get saved value, else 11
                      alert("checkMe = "+checkMe)
                        }
                    if(checkMe == 11){
                        checkMe= false;   //if there is no saved settings, checkbox value will be false/ unchecked
                        alert("You run this script first time, so manual value will be 'false'")
                        }else{
                            checkMe = app.settings.getSetting("savea", "chck");     // if saved settings exist, get true or false
                        }
     alert("Yes, checkMe will = "+checkMe)        
    
    
win.checkPanel.chkOne.value = checkMe;  /// checkbox value will equal saved checkMe
 
var fff = win.checkPanel.chkOne.value;  // string for alert
 alert("aha! but checkbox value is  = " +fff+ "\n Why so?")     // here we`ve got always "true"
 
 
 
 
win.checkPanel.chkOne.onClick  = function () {
        
    var path11 = win.checkPanel.chkOne.value;  //  checkbox value to variable
    app.settings.saveSetting("savea", "chck", path11);  //saving checkbox value
    alert("Saved this value - " + app.settings.getSetting("savea", "chck"))
          }
 
 
 
 
 
 
          win.quitBtn.onClick = function() { 
              win.close(); 
          }
 
 
    win.center();
          win.show();
 
 
          return retval;
  
}
 
 
if(typeof(mainFun_unitTest) == "undefined") {
    new mainFun().run();
}
 
 
Replies
  • Currently Being Moderated
    Jul 3, 2012 4:56 PM   in reply to Alex Grey

    At a quick glance, I'd say it's because when the pref is saved it's saved as a string, so after reading it you should be checking if (checkMe == "true") rather than checking it as a boolean.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points