# Button.\_visible with LoadVars

**URL:** <https://forum.kirupa.com/t/button--visible-with-loadvars/64557>\
**Category:** Uncategorized\
**Created:** [September 17, 2004, 1:40pm UTC](https://forum.kirupa.com/t/button--visible-with-loadvars/64557 "2004-09-17T13:40:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![guyute](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/guyute/32/763_2.png) [@guyute](https://forum.kirupa.com/u/guyute)\
**Post date:** [September 17, 2004, 1:40pm UTC](https://forum.kirupa.com/t/button--visible-with-loadvars/64557/1 "2004-09-17T13:40:07Z")

</div>

I’m working on a site that has dynamically loaded text menu loaded with the following action:

myData = new LoadVars();  
myData.load(“menu/menu01.txt”);  
myData.ref = this;  
myData.onLoad = function(succes) {  
if (succes) {  
for (var i = 0; i\<this.cant; i++) {  
this.ref[“title\_txt”+i].htmlText = this[“Title”+i];  
this.ref[“link”+i].htmlText = this[“link”+i];  
}  
} else {  
trace(“Error loading data”);  
}  
};

which loads this text from menu/menu01.txt:

Title0=TITLE HERE &link0=FIRST LINK&link1=SECOND LINK&link2=&link3=&link4=&link5=&link6=&link7=&link8=&link9=&link10=&link11=&link 12=&link13=&link14=&cant=15

what i would like to know, since this is new to me, is can i have a button instance on the stage under each variable from menu01.txt, and set the buttons to \_visible=true; or \_visible=false; depending on wether or not there was text loaded in the dynamic text field? also, how can i get flash to recognize wether or not text was loaded or not loaded if the var is empty?

thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 18, 2004, 4:24am UTC](https://forum.kirupa.com/t/button--visible-with-loadvars/64557/2 "2004-09-18T04:24:55Z")

</div>

you need 4 frames  
// frame 1  
for(i= 1 to n)  
linkN.\_visible = false;  
// frame 2  
myData = new LoadVars(); …  
// frame 3  
for(i= 1 to n)  
if( myData.linkN != “”)  
btnLinkN.\_visible = true;

this is not exact code but pseudocode. just to give you the idea.

happy actionscripting

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 18, 2004, 7:10pm UTC](https://forum.kirupa.com/t/button--visible-with-loadvars/64557/3 "2004-09-18T19:10:34Z")

</div>

not sure i follow you. in particular the “n” here: (i= 1 to n) and what the LinkN represents. Can anyone help me out with a little more of a hint?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 19, 2004, 10:05pm UTC](https://forum.kirupa.com/t/button--visible-with-loadvars/64557/4 "2004-09-19T22:05:25Z")

</div>

You could try writing a conditional to test if the text field has anything in it at all. For example.

if(mytext\_txt.text !=""){  
mymc\_mc.\_visible=true  
}else{  
mymc\_mc.\_visible=false  
}

That may or may not be what you’re lookin for. Either way, hope it helps.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 8:42am UTC](https://forum.kirupa.com/t/button--visible-with-loadvars/64557/5 "2004-09-20T08:42:11Z")

</div>

linkN means link + N

this.ref[“title\_txt”+i].htmlText = this[“Title”+i];  
this.ref[“link”+i].htmlText = this[“link”+i];

in your case this.ref[“title\_txt”+i] this.ref[“title\_txt”+N].
