# XML driven menu spacing in flash isn't working, can anyone help? Driving me mad! Tha

**URL:** <https://forum.kirupa.com/t/xml-driven-menu-spacing-in-flash-isnt-working-can-anyone-help-driving-me-mad-tha/315838>\
**Category:** Uncategorized\
**Created:** [November 5, 2010, 11:25am UTC](https://forum.kirupa.com/t/xml-driven-menu-spacing-in-flash-isnt-working-can-anyone-help-driving-me-mad-tha/315838 "2010-11-05T11:25:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cuz83](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@cuz83](https://forum.kirupa.com/u/cuz83)\
**Post date:** [November 5, 2010, 11:25am UTC](https://forum.kirupa.com/t/xml-driven-menu-spacing-in-flash-isnt-working-can-anyone-help-driving-me-mad-tha/315838/1 "2010-11-05T11:25:27Z")

</div>

Hi, This is driving me potty and I can’t work it out! I was wondering if anyone has done this before.

In summary, I have an XML document that I am loading into flash to compose a menu dynamically.

Here is what it looks like so far: [http://ian.greensplash.com/issue.jpg](http://ian.greensplash.com/issue.jpg) - very early stages!

So I have a for loop getting the content out of my XML, then populating 2 dynamic text boxes, the title, eg: “module X” and description, eg:: “Lorem ipsum”

So the looping is fine.

What I can’t work out is how to space the objects on the stage evenly because the description is different, thus different heights.

I can space them with a set number for .\_y, but I cant work out how to space them nicely. Notice the bigger gap on my link above. The issue is if there is a long description, then the menu items will overlap,

This is my AS. (2.0) (excuse the $'s, habit from using php, but stands out more to me in my AS.)

```auto

            $objMainMenuData=$myXML.firstChild.childNodes; //array of first nodes
            

            for (i=0;i<$objMainMenuData.length;i++)
            {
                //trace(objMainMenuData*.attributes.text); // loop the test attributes
                $mainMenuBut=_root.attachMovie('mainMenuModuleBut', 'but'+i,_root.getNextHighestDepth());

                trace("my loop is at i :" + i)
                $mainMenuBut._x=40;
                
                // update the text on button
                trace("module name: " + $objMainMenuData*.firstChild.firstChild.nodeValue);
                $mainMenuBut.dtxtModuleName.text=$objMainMenuData*.firstChild.firstChild.nodeValue;
                
                //get the module's summary
                $mainMenuBut.$moduleSummary=$objMainMenuData*.firstChild.nextSibling.nextSibling.firstChild.nodeValue;
                trace("the summary description is: " + $mainMenuBut.$moduleSummary);
                $mainMenuBut.dtxtModuleDescription.text=$objMainMenuData*.firstChild.nextSibling.nextSibling.firstChild.nodeValue;
                
                // spacing
                $mainMenuBut.dtxtModuleDescription.autoSize = "center";
                trace("height of description is: " + $mainMenuBut.dtxtModuleDescription._height);
                $mainMenuBut.mainMenuModuleButBG._height=($mainMenuBut.dtxtModuleDescription._height)+45;
                $ModuleDescriptionHeight_dtxt=$mainMenuBut.dtxtModuleDescription._height;
                //space the items nicely.
                trace("trying current height: "+$mainMenuBut.dtxtModuleDescription._height);
                $mainMenuBut._y=(i*115)+125; //space them out, but start with a 125 indent;

                //get the right link for the button
                $mainMenuBut.$moduleButtonLink=$objMainMenuData*.firstChild.nextSibling.firstChild.nodeValue;
                trace("the module button link is: " + $mainMenuBut.$moduleButtonLink);
                
                $mainMenuBut.onRelease=function()
                {
                    $newModuleButtonLink=this.$moduleButtonLink
                    trace("ok the still is : "+ $newModuleButtonLink);
                }
                
                    $mainMenuBut.onRollOver=function()
                    {
                        this.mainMenuModuleButBG._alpha=80;
                    }
                    
                    $mainMenuBut.onRollOut=function()
                    {
                        this.mainMenuModuleButBG._alpha=100;
                    }

```

Any help will be extremely welcomed!

Thanks in advance!

Ian
