# Using a variable

**URL:** <https://forum.kirupa.com/t/using-a-variable/11637>\
**Category:** flash\
**Created:** [January 20, 2003, 2:58pm UTC](https://forum.kirupa.com/t/using-a-variable/11637 "2003-01-20T14:58:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![barzalou1](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@barzalou1](https://forum.kirupa.com/u/barzalou1)\
**Post date:** [January 20, 2003, 2:58pm UTC](https://forum.kirupa.com/t/using-a-variable/11637/1 "2003-01-20T14:58:53Z")

</div>

Hi,

I have a question about how to incorporate a variable in a certain line of code inside a function. Here goes :

function menu(new\_document) {  
document = new document  
… some other code  
\_root.document.\_visible = 0;  
}

In this case, I want to use the string value of the variable “document” and render it invisible. I am sure that the syntax that I used is wrong. I did verify that the the function recognize the value of “new\_document” by using “Trace” and it does.

Could someone steer me in the right direction ?

Thank you

---

<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:** [January 20, 2003, 3:21pm UTC](https://forum.kirupa.com/t/using-a-variable/11637/2 "2003-01-20T15:21:49Z")

</div>

dot syntax uses object references to reach an object or property. If you are using strings, you need to use associative array referencing, meaning using [string] instead of .object  
ex:

\_root.movieclip1.\_visible = false

could also be written as

\_root[“movieclip1”].\_visible = false

for more information see [http://www.kirupaforum.com/showthread.php?s=&threadid=12082](http://www.kirupaforum.com/showthread.php?s=&threadid=12082)

---

<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:** [January 21, 2003, 1:00am UTC](https://forum.kirupa.com/t/using-a-variable/11637/3 "2003-01-21T01:00:01Z")

</div>

:nerd: thank you very much for your help. The answer that I neede was almost exactly what you gave me :

\_root[document].\_visible = 0 ;

thanx again

Barzalou1
