# Set layer visibility dynamically. Please help!

**URL:** <https://forum.kirupa.com/t/set-layer-visibility-dynamically-please-help/253066>\
**Category:** Uncategorized\
**Created:** [February 26, 2008, 9:31pm UTC](https://forum.kirupa.com/t/set-layer-visibility-dynamically-please-help/253066 "2008-02-26T21:31:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franck69](https://avatars.discourse-cdn.com/v4/letter/f/f0a364/32.png) [@Franck69](https://forum.kirupa.com/u/Franck69)\
**Post date:** [February 26, 2008, 9:31pm UTC](https://forum.kirupa.com/t/set-layer-visibility-dynamically-please-help/253066/1 "2008-02-26T21:31:41Z")

</div>

Hi there,

I need a little help to resolve this in AS 2.0 Flash 8:

I want to load status from a txt file, to retrieve which one of 3 layers should be visible in order to display the status of each of 40 lands to be sell on my a map.  
The content of my text file is organized like this:

lot\_01\_a=false&lot\_01\_v=true&lot\_01\_c=false&lot\_02 \_a=true&lot\_02\_v=false&lot\_02\_c=false…

Here is my AS:

myVariables = new LoadVars();  
myVariables.load(“terrains.txt”);  
myVariables.onLoad = function(success){  
if(success){  
for (var i = 1; i\<41; i++) {  
if(i \< 10){  
trace(“test: “+this[“lot\_0”+i+”\_a”]); // OK display “test: false” (as example)  
trace(“test: “+this[“lot\_0”+i+”\_v”]); // OK display “test: true” (as example)  
trace(“test: “+this[“lot\_0”+i+”\_c”]); // OK display “test: false” (as example)  
// HERE I NEED TO SET MY LAYER VISIBILITY AND IT NEVER WORKS !!!  
eval(“lot\_0”+i+"\_a").\_visible = eval(this[“lot\_0”+i+"\_a"]); // DON’T WORK  
eval(“lot\_0”+i+"\_v").\_visible = eval(this[“lot\_0”+i+"\_v"]); // DON’T WORK  
eval(“lot\_0”+i+"\_c").\_visible = eval(this[“lot\_0”+i+“_c"]); // DON’T WORK  
}  
else{  
// HERE I NEED TO SET MY LAYER VISIBILITY AND IT NEVER WORKS !!!  
//set ("lot_”+i+"\_a._visible", eval(this["lot_"+i+“_a"])); // DON’T WORK  
//set ("lot_”+i+"\_v._visible", eval(this["lot_"+i+“_v"])); // DON’T WORK  
//set ("lot_”+i+"\_c._visible", eval(this["lot_"+i+“_c"])); // DON’T WORK  
//setProperty(eval("lot_”+i+"\_a"), _visible, this["lot_"+i+“_a"]); // DON’T WORK  
//setProperty(eval("lot_”+i+"\_v"), _visible, this["lot_"+i+“_v"]); // DON’T WORK  
//setProperty(eval("lot_”+i+"\_c"), _visible, this["lot_"+i+“_c"]); // DON’T WORK  
//eval("lot_”+i+"\_a")._visible = this["lot_"+i+“_a"]; // DON’T WORK  
//eval("lot_”+i+"\_v")._visible = this["lot_"+i+“_v"]; // DON’T WORK  
//eval("lot_”+i+"\_c")._visible = this["lot_"+i+“_c"]; // DON’T WORK  
this["lot_”+i+"\_a"]._visible = this["lot_"+i+“_a"]; // DON’T WORK  
this["lot_”+i+"\_v"]._visible = this["lot_"+i+“_v"]; // DON’T WORK  
this["lot_”+i+"\_c"]._visible = this["lot_"+i+"\_c"]; // DON’T WORK  
}  
}  
}  
else {  
trace(“there was a problem loading the variables”);  
}  
}

As you could see I tried a lot of things without success.  
However, the following with hardcoded values works well wich tells me that my instance are correctly named:  
eval(“lot\_0”+i+"\_a").\_visible = false; // WORKS !!!  
eval(“lot\_0”+i+"\_a").\_visible = true; // WORKS !!!  
eval(“lot\_0”+i+"\_a").\_visible = false; // WORKS !!!

Thank’s a lot for helping…:red:
