[SOLVED] Dynamic property on '.enabled = false;'

Hello,

I need to run through a list of names (being named entities with a “this.” in front), in order to make all but specific visible entity, invisible;

MouseTouch_Explainer.prototype.allOtherNotEnabled = function(allButNowVisible){
    var listOfAll = ['entityMSL','entityMSR','entityMSW_ZoomIn','entityMSW_ZoomOut']; 
    for(var i=0; i<listOfAll.length;i++){        
            var thisStr = "this.";   var thisPlusABNV = thisStr+listOfAll[i]; console.log("listOfAll[i]: "+thisPlusABNV);
        var myobj = {a : thisStr, b : thisPlusABNV};

        var dynamicProperty1 = 'a';
        var dynamicProperty2 = 'b';
         if(thisPlusABNV!==allButNowVisible){
                thisPlusABNV.enabled = false;console.log("list INS");
           }
        }
};
  • cannot workout how to combine the strings and the ‘.enabled’-ending?

In the stackoverflow link, the relevant line is:

ie myobj.a could also be referenced as myobj['a'].

Right now, the code you have posted is just concatenating two strings together. You have the right idea, but the implementation isn’t quite there yet.

ok, tried that and what is possible, otherwise I guess. At least I had a backup in mind (writing [SOLVED]), which is less pretty. This is what I ended up with (including setting this.visState at all other events :-/ ):

MouseTouch_Explainer.prototype.allOtherNotEnabled = function(){
   /* var listOfAll = ['entityMSL','entityMSR','entityMSW_ZoomIn','entityMSW_ZoomOut']; 
    for(var i=0; i<listOfAll.length;i++){        
            var thisStr = "this.";   var thisPlusABNV = thisStr+listOfAll[i]; console.log("listOfAll[i]: "+thisPlusABNV);
        var myobj = { b : thisPlusABNV};

        var dynamicProperty1 = 'a';
        var dynamicProperty2 = 'b';
         if(myobj.b!==allButNowVisible){
                myobj.b.enabled = false;console.log("list INS");
           }
        }*/
    this.entityMSL.enabled = false;  this.entityMSR.enabled = false;     this.entityMSW_ZoomIn.enabled = false;  this.entityMSW_ZoomOut.enabled = false;     this.entityMSLoo.enabled = false;  this.entityMSRpo.enabled = false;      
    this.entityMS1stTouch.enabled = false; this.entityMSLastTouch.enabled = false; 
    
    this.entityHALoo.enabled = false;  this.entityHARpo.enabled = false;     this.entityHATwoTouch.enabled = false;     this.entityHA_ZoomIn.enabled = false;  this.entityHA_ZoomOut.enabled = false; 
    
    switch(this.visState) {
  case 1:
    // code block
          this.entityMSL.enabled = true;  
    break;
  case 2:
    // code block
          this.entityMSR.enabled = true;  
    break;
  case 3:
    // code block
            
    break;
  case 4:
    // code block
    break;
  case 5:
    // code block
    break;
  case 6:
    // code block
            this.entityMSW_ZoomIn.enabled = true;  
    break;
  case 7:
    // code block
            this.entityMSW_ZoomOut.enabled = true;  
    break;
  case 8:
    // code block
    break;
  default:
    // code block
}
};

I would expect the following to work:

MouseTouch_Explainer.prototype.allOtherNotEnabled = function (allButNowVisible) {
    var listOfAll = ['entityMSL', 'entityMSR', 'entityMSW_ZoomIn', 'entityMSW_ZoomOut'];
    for (var i = 0; i < listOfAll.length; i++) {
        var thisPlusABNV = this[listOfAll[i]];
        
        if (thisPlusABNV !== allButNowVisible) {
            thisPlusABNV.enabled = false;
            console.log("list INS");
        }
    }
};

ok, I think I tried that also - but thx