Dynamic Menu AS2 (Flash 8 & above)

Hi.

I’m trying to build a completely dynamic menu (with submenus) using all code (no frame labels, timeline etc). I’m kinda stuck and am not 100% sure how to get to the next step (making the main menu buttons move to allow the submenu to appear in between the appropriate spot). I think it’s just easier for you to take a look at the code to see where I’m at. Here it is:

var ChapterTitles_arr:Array = new Array();
ChapterTitles_arr[0] = “Chapter0”;
ChapterTitles_arr[1] = “Chapter1”;
ChapterTitles_arr[2] = “Chapter2”;
ChapterTitles_arr[3] = “Chapter3”;
ChapterTitles_arr[4] = “Chapter4”;
ChapterTitles_arr[5] = “Chapter5”;
ChapterTitles_arr[6] = “Chapter6”;

var SubMenus_0_arr:Array = new Array();
SubMenus_0_arr[0] = “Chapter0 Sub Menu1”;
SubMenus_0_arr[1] = “Chapter0 Sub Menu2”;
SubMenus_0_arr[2] = “Chapter0 Sub Menu3”;

var SubMenus_1_arr:Array = new Array();
SubMenus_1_arr[0] = “Chapter1 Sub Menu1”;
SubMenus_1_arr[1] = “Chapter1 Sub Menu2”;
SubMenus_1_arr[2] = “Chapter1 Sub Menu3”;
SubMenus_1_arr[3] = “Chapter1 Sub Menu4”;
SubMenus_1_arr[4] = “Chapter1 Sub Menu5”;
SubMenus_1_arr[5] = “Chapter1 Sub Menu6”;

var SubMenus_2_arr:Array = new Array();
SubMenus_2_arr[0] = “Chapter2 Sub Menu1”;
SubMenus_2_arr[1] = “Chapter2 Sub Menu2”;
SubMenus_2_arr[2] = “Chapter2 Sub Menu3”;
SubMenus_2_arr[3] = “Chapter2 Sub Menu4”;
SubMenus_2_arr[4] = “Chapter2 Sub Menu5”;

var SubMenus_3_arr:Array = new Array();
SubMenus_3_arr[0] = “Chapter3 Sub Menu1”;
SubMenus_3_arr[1] = “Chapter3 Sub Menu2”;

var SubMenus_4_arr:Array = new Array();
SubMenus_4_arr[0] = “Chapter4 Sub Menu1”;
SubMenus_4_arr[1] = “Chapter4 Sub Menu2”;
SubMenus_4_arr[2] = “Chapter4 Sub Menu3”;
SubMenus_4_arr[3] = “Chapter4 Sub Menu4”;
SubMenus_4_arr[4] = “Chapter4 Sub Menu5”;
SubMenus_4_arr[5] = “Chapter4 Sub Menu6”;

var SubMenus_5_arr:Array = new Array();
SubMenus_5_arr[0] = “Chapter5 Sub Menu1”;
SubMenus_5_arr[1] = “Chapter5 Sub Menu2”;
SubMenus_5_arr[2] = “Chapter5 Sub Menu3”;

var SubMenus_6_arr:Array = new Array();
SubMenus_6_arr[0] = “Chapter6 Sub Menu1”;
SubMenus_6_arr[1] = “Chapter6 Sub Menu2”;
SubMenus_6_arr[2] = “Chapter6 Sub Menu3”;

createMainMenu = function () {

distance_var = 0;

for (i=0; i<ChapterTitles_arr.length; i++) {
	
	ref = empty_mc.attachMovie("mainMenu_btn_mc", "mainMenuButton"+i, 1+i);
	ref.textField_tf.text = ChapterTitles_arr*;
	
	mcHeight = ref._height;
	ref._y = distance_var;
	distance_var += mcHeight;
	
	ref.chapter_id = i;
	
	ref.onRelease = function() {
		
		distanceA_var = this._y + empty_mc.mainMenuButton0._height;
		
		this._parent._parent.empty_mc.createEmptyMovieClip("subMenuContainer_mc",25);
		empty_mc.subMenuContainer_mc._x = 65;
		
		for (j=0; j<this._parent._parent["SubMenus_"+this.chapter_id+"_arr"].length; j++) {
			var SubMenu = this._parent._parent.empty_mc.subMenuContainer_mc.attachMovie("subMenu_btn_mc", "newSubMenuBut"+j, 30+j);
			
	SubMenu.textFieldSub_tf.text = this._parent._parent["SubMenus_"+this.chapter_id+"_arr"][j];
			
			mcHeightA = SubMenu._height +1;
			
			SubMenu._y = distanceA_var;
			distanceA_var += mcHeightA				
			
		}
		
	};
	
}

};

createMainMenu();

// inside the .fla file I have one empty movie clip on the stage (empty_mc) and two buttons //in the library with linkage (mainMenu_btn_mc) & (subMenu_btn_mc)