Get the height after attachmovie?


var menuArray:Array = ["tab1", "tab2", "tab main 3", "tab4", "tab5"];
var submenuArray:Array = [[], ["subTab 2A", "subTab 2B", "subTab 2C"], ["subTab 3A", "subTab 3B"], [], ["subTab 5A", "subTab 5B", "subTab 5C", "subTab 5D"]];
function buildMenu(thisArray) {
	for (var i = 0; i<thisArray.length; i++) {
		var mainMenu:MovieClip;
		var curr_item:MovieClip;
		var mainMenu = container.createEmptyMovieClip("mainMenu", i);
		curr_item = mainMenu.attachMovie("menuItem", "menuItem"+i, 5+i);
		curr_item._y = 15+i*40;
		curr_item._x = 20;
		curr_item.menuText.autoSize = true;
		curr_item.menuText.multiline = false;
		curr_item.menuText.condenseWhite = true;
		curr_item.menuText.text = ucfirst(thisArray*);
		curr_item.menuItemBG_mc._width = Math.floor(curr_item.menuText._width)+15;
		//check if curr_item has a subMenu 
		if (submenuArray* != '') {
			trace(submenuArray*.length);			
			for (var j:Number = 0; j<submenuArray*.length; j++) {
				var subMenu = curr_item.createEmptyMovieClip("subMenu"+i, j);
				//trace(submenuArray[j])
				curr_subitem = subMenu.attachMovie("menuItem", "subMenuItem"+j, 10+i);
				curr_subitem._y = 5+j*40;
				curr_subitem._x = 100;
				curr_subitem.menuText.autoSize = true;
				curr_subitem.menuText.multiline = false;
				curr_subitem.menuText.condenseWhite = true;
				curr_subitem.menuText.text = ucfirst(submenuArray*[j]);
				curr_subitem.menuItemBG_mc._width = Math.floor(curr_subitem.menuText._width)+15;
				//hide our submenu
				subMenu._visible = false;
				//we need the height of submenu for our mask
			}
			curr_item.id = i;
			curr_item.submenuH = submenuArray*.length*subMenu._height;
			trace("Submenu height: "+submenuArray*.length*subMenu._height);
		}
		curr_item.onRelease = function() {
			test = this["subMenu"+this.id]._height;
			trace(test);
			trace("Clicked and Height: "+this.submenuH);
			this["subMenu"+this.id]._visible = true;
		};
	}
	//setSubmenuMask(container, 0, 0, 250, 150);
}


I just see one subItem when i click

So i guess the height of subMenu isn’t correct
this part:


for (var j:Number = 0; j<submenuArray*.length; j++) {
				var subMenu = curr_item.createEmptyMovieClip("subMenu"+i, j);
				curr_subitem = subMenu.attachMovie("menuItem", "subMenuItem"+j, 10+i);
				

but subMenu._height just gives me the height of 1 menuItem symbol

I think its because you’re overwriting subMenu each time in your loop - thats creating JTotal amount of subMenu.

Change this:


 //check if curr_item has a subMenu 
        if (submenuArray* != '') {
            trace(submenuArray*.length);      
            for (var j:Number = 0; j<submenuArray*.length; j++) {
                var subMenu = curr_item.createEmptyMovieClip("subMenu"+i, j);
                //trace(submenuArray[j])

To this:


 //check if curr_item has a subMenu 
        if (submenuArray* != '') {
            //OUTSIDE THE LOOP
            var subMenu:MovieClip = curr_item.createEmptyMovieClip("subMenu"+i, curr_item.getNextHighestDepth());
            trace(submenuArray*.length);      
            for (var j:Number = 0; j<submenuArray*.length; j++) {
               //trace(submenuArray[j])

Think thats in? Hope this helps.