Using a variable

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

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

: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