Help with dynamic menu

Hello. I have a little problem. Currently I have a vertical menu which is generated via xml. Each menu item also has its own sub menu (not shown). When clicking on the top level item i want the rest of the items to move down to show the sub navigation. ie

menu item 1
menu item 2
menu item 3
menu item 4


menu item 1
sub menu 1
sub menu 2
sub menu 3
menu item 2
menu item 3
menu item 4

I have that working fine, but i havnt a clue how to fix it. Say if i have clicked on menu item 1, and the sub menu is displaying, before i have can view another sub menu i have to click on menu item 1 to close it before I can click on menu item 2.

this is the code that im using to tell weather or not to move the buttons up or down:


menuButton.clicked = false;
menuButton.onRelease = function () { 
    if(menuButton.clicked == false) {
        _root.moveMovieDown(buttonNum, buttonHeights);
        menuButton.clicked = true;
    } else {
        _root.moveMovieUp(buttonNum); 
        menuButton.clicked = false; 
    }
}

Basicly i want to be able to click on any menu item button, if a menu item is open, i want it to close, and then open the new one. just like this one. http://www.bridgehead.com.au/case.php

hope it makes sense :slight_smile: