Building menu from XML

I don’t understand how to build the menu from the XML file I am using. Where I am having trouble is getting the menu button text to appear and how to set up the sub menu items. In my function buildButtons() I can get the main buttons to show minus text but no sub menu buttons. Any help appreciated.

http://dev.webriverinteractive.com/pegasus/pegasus1to1.html


//create menu
function createMenu():void {
    //get info
    for each (var node:XML in navData) {
        //trace(node.name.toString());
        infoName=node.info.name.toString();
        infoClient=node.info.client.toString();
        infoCreator=node.info.creator.toString();
        //place text in text fields
        pname.text=infoName;
        client.text=infoClient;
        creator.text=infoCreator;
    }


    // Determine unique category names 
    var categoryNames:Array=[];
    var categories:XMLList=navData..categoryName;
    for (var i:int = 0; i < categories.length(); i++) {
        var categoryName:String=categories*;
        if (categoryNames.indexOf(categoryName)==-1) {
            categoryNames.push(categoryName);
        }
    }

    // Build menu based on categories 
    for (i = 0; i < categoryNames.length; i++) {
        trace("Top level:", categoryNames*);
        var pages:XMLList = navData..page.(categoryName == categoryNames*);
        for (var p:int = 0; p < pages.length(); p++) {
            trace(" -> Subpage:", pages[p].pageName);
        }
        buildButtons();
    }

}

var yPlacement:int=150;// Set the "y" location on stage where the first btn will live
var xPlacement:int=10;// Set the "x" location on stage where all btns will line up vertically
// Format the text appearance here
var format:TextFormat = new TextFormat();
format.color=0x000000;
format.font="Arial";
format.size=12;
//format.bold = true;
format.kerning=false;


function buildButtons():void {
    // This all pertains to the style of the button, alter values to your liking
    var type:String=GradientType.LINEAR;
    var colors:Array=[0xFFFFFF,0xCCCCCC];
    var alphas:Array=[1,1];
    var ratios:Array=[0,255];
    var spreadMethod:String=SpreadMethod.PAD;
    var interp:String=InterpolationMethod.LINEAR_RGB;
    var focalPtRatio:Number=0;
    var matrix:Matrix = new Matrix();
    var boxWidth:Number=100;
    var boxHeight:Number=20;
    var boxRotation:Number=Math.PI/2;// 90&#730;
    var tx:Number=0;
    var ty:Number=0;
    matrix.createGradientBox(boxWidth, boxHeight, boxRotation, tx, ty);
    var rect:Shape=new Shape  ;
    rect.graphics.beginGradientFill(type, colors, alphas, ratios, matrix, spreadMethod, interp, focalPtRatio);
    rect.graphics.lineStyle(1, 0x999999);
    rect.graphics.drawRect(0, 0, 100, 20);

    // This all pertains to the text fields that give our buttons their label, alter values to your liking
    var myText:TextField = new TextField();
    //myText.embedFonts = true;
    myText.autoSize=TextFieldAutoSize.LEFT;
    myText.antiAliasType=AntiAliasType.ADVANCED;
    myText.defaultTextFormat=format;
    myText.selectable=false;
    myText.mouseEnabled=false;
    //myText.text=listLabel;
    //myText.text=categoryName;//throws error access of undefined property
    myText.text="";
    myText.x=2;
    myText.y=2;
    addChild(myText);

    // Create MovieClip holder for each button graphic and text label
    var clip_mc = new MovieClip();
    // Add the rectangle graphic
    clip_mc.addChild(rect);
    // Add the text field
    clip_mc.addChild(myText);
    // Put the new movieClip on stage now
    addChild(clip_mc);
    // Make the mouse button mode true for the movieclip so user knows it is a button
    clip_mc.buttonMode=true;

    //for horizontal menu
    clip_mc.y=yPlacement;
    clip_mc.x=xPlacement;
    xPlacement=xPlacement+110;

    // Access the URL value and ready it for setting up the Click listener, and function
    clip_mc.clickToPage=pageCategory;
    // Add the mouse event listener to the moviClip button
    clip_mc.addEventListener(MouseEvent.CLICK, clipClick);
    //Add event listeners (used for animating the buttons)
    clip_mc.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    clip_mc.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
    clip_mc.addEventListener(MouseEvent.CLICK, clipClick);
}

// Set the function for what happens when that button gets clicked
function clipClick(e:Event):void {
    //var targetURL:String=e.target.clickToPage;
    //var urlRequest:URLRequest=new URLRequest(targetURL);
    //navigateToURL(urlRequest);
    outText.text=e.target.clickToPage;
}