# Xml menu positioning problem

**URL:** <https://forum.kirupa.com/t/xml-menu-positioning-problem/184124>\
**Category:** Uncategorized\
**Created:** [April 2, 2006, 11:46am UTC](https://forum.kirupa.com/t/xml-menu-positioning-problem/184124 "2006-04-02T11:46:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pyro3k](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@pyro3k](https://forum.kirupa.com/u/pyro3k)\
**Post date:** [April 2, 2006, 11:46am UTC](https://forum.kirupa.com/t/xml-menu-positioning-problem/184124/1 "2006-04-02T11:46:30Z")

</div>

ok this i sbugging me so i hope someone can help

i have an xml file which i am reading into flash and then looping though and displaying the data in a movieclip.

i was using the below code which was working fine

there is a movieclip on the main stage called menu\_mc

```auto
var xml : XML = new XML();
xml.ignoreWhite = true;
xml.load( "menu.xml" );

xml.onLoad = function()
{
    topics = xml.firstChild.childNodes;
    var currentY = 0;
    var index = 0
        
    for ( var i = 0 ; i < topics.length ; i++ )
    {
        var topic : Array = topics*;
        var posts : Array = topic.firstChild.childNodes;
                
        menu_mc.createEmptyMovieClip( "topic_mc" + index , menu_mc.getNextHighestDepth() );
        var topic_mc : MovieClip = menu_mc["topic_mc" + index];
        topic_mc._y += 20 * currentY;
        topic_mc.createTextField( "topic_txt" + index , topic_mc.getNextHighestDepth() , 50 , 50 , 300 , 20 );
        var topic_txt : TextField = topic_mc["topic_txt" + index];
        topic_txt.text = topics*.attributes.name;
            
        currentY++;
            
        for ( var j = 0 ; j < posts.length ; j++ )
        {
            var post : Array = posts[j];
                
            menu_mc.createEmptyMovieClip( "post_mc" + index , menu_mc.getNextHighestDepth() );
            var post_mc : MovieClip = menu_mc["post_mc" + index];
            post_mc._x = 10;
            post_mc._y += 20 * currentY;
            post_mc.createTextField( "post_txt" + index , post_mc.getNextHighestDepth() , 50 , 50 , 300 , 20 );
            var post_txt : TextField = post_mc["post_txt" + index];
            post_txt.text = posts[j].attributes.name;
                
            currentY++;
            index++;
        }
    }
}

```

this produced the following results which is how i wanted it to look.

[![](http://img240.imageshack.us/img240/4259/15jj2.jpg)](http://imageshack.us)

but i want the post movieclips to be inside there parent topic clip.

so i changed my code to do this to the following

```auto
var xml : XML = new XML();
xml.ignoreWhite = true;
xml.load( "menu.xml" );

xml.onLoad = function()
{
    topics = xml.firstChild.childNodes;
    var currentY = 0;
    var index = 0
        
    for ( var i = 0 ; i < topics.length ; i++ )
    {
        var topic : Array = topics*;
        var posts : Array = topic.firstChild.childNodes;
                
        menu_mc.createEmptyMovieClip( "topic_mc" + index , menu_mc.getNextHighestDepth() );
        var topic_mc : MovieClip = menu_mc["topic_mc" + index];
        topic_mc._y += 20 * currentY;
        topic_mc.createTextField( "topic_txt" + index , topic_mc.getNextHighestDepth() , 50 , 50 , 300 , 20 );
        var topic_txt : TextField = topic_mc["topic_txt" + index];
        topic_txt.text = topics*.attributes.name;
            
        currentY++;
            
        for ( var j = 0 ; j < posts.length ; j++ )
        {
            var post : Array = posts[j];
                
            topic_mc.createEmptyMovieClip( "post_mc" + index , topic_mc.getNextHighestDepth() );
            var post_mc : MovieClip = topic_mc["post_mc" + index];
            post_mc._x = 10;
            post_mc._y += 20 * currentY;
            post_mc.createTextField( "post_txt" + index , post_mc.getNextHighestDepth() , 50 , 50 , 300 , 20 );
            var post_txt : TextField = post_mc["post_txt" + index];
            post_txt.text = posts[j].attributes.name;
                
            currentY++;
            index++;
        }
    }
}

```

but now the results look like this

[![](http://img205.imageshack.us/img205/3693/24oz1.jpg)](http://imageshack.us)

any ideas what is making this happen?
