Menu Script HELP!

I found some code in a tutorial and I am having problems making it work. I have updated all the code and everything seems to check out accept this bit of code.

function setMenuClose() {
    for (z==1; z<10; z++) {
        if (eval("menuleftopen"+z) == true) {
            eval("menu.menu"+z).gotoAndPlay("Swoop Up");
        }
    }
}
stop();

You may have seen this before. Hope so. This checks through a series of menu items and variables. Can anyone help??! Thanks a bunch.