Problem with collapsing menu

Hi :wink: I have downloaded menu which is using xml. This is the AS


// -- < Load XML Data > -- \\
var menu_xml:XML = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok) {
    if (ok) {
        var menuItems = this.firstChild.childNodes;
        var totalHeight:Number = 0;
        var theLinks:Array = [];
        var theBtns:Array = [];
        _root.createEmptyMovieClip("mainMenu", 999);
        for (q=0; q<menuItems.length; q++) {
            var sectionTitle = menuItems[q].attributes.title;
            _root.mainMenu.createEmptyMovieClip(sectionTitle, q);
            //
            _root.mainMenu[sectionTitle].createTextField("theLabel", q+50, _root.mainMenu[sectionTitle]._x, _root.mainMenu[sectionTitle]._y, _root.mainMenu[sectionTitle]._width, _root.mainMenu[sectionTitle]._height-2);
            var myformat:TextFormat = new TextFormat();
            myformat.font = "Arial";
            myformat.size = 11;
            _root.mainMenu[sectionTitle].theLabel.selectable = false;
            _root.mainMenu[sectionTitle].theLabel.autoSize = true;
            _root.mainMenu[sectionTitle].theLabel.text = sectionTitle;
            _root.mainMenu[sectionTitle].theLabel.setTextFormat(myformat);
            //
            _root.mainMenu[sectionTitle].attachMovie("sectionClip", "title", q+1);
            for (w=0; w<menuItems[q].childNodes.length; w++) {
                var subSectionTitle = menuItems[q].childNodes[w].attributes.subTitle;
                var linkage:String = menuItems[q].childNodes[w].attributes.theurl;
                _root.mainMenu[sectionTitle].attachMovie("itemButton", subSectionTitle, w*20);
                theBtns.push(_root.mainMenu[sectionTitle][subSectionTitle]);
                theLinks.push(linkage);
                _root.mainMenu[sectionTitle][subSectionTitle].myLink = linkage;
                _root.mainMenu[sectionTitle][subSectionTitle]._y = (w*(_root.mainMenu[sectionTitle][subSectionTitle]._height)+_root.mainMenu[sectionTitle][subSectionTitle]._height);
                //
                _root.mainMenu[sectionTitle][subSectionTitle].createTextField("theLabel", q+50, _root.mainMenu[sectionTitle]._x, _root.mainMenu[sectionTitle]._y, _root.mainMenu[sectionTitle]._width, _root.mainMenu[sectionTitle]._height-2);
                var myformat:TextFormat = new TextFormat();
                myformat.font = "Arial";
                myformat.size = 11;
                myformat.indent = 15;
                _root.mainMenu[sectionTitle][subSectionTitle].theLabel.selectable = false;
                _root.mainMenu[sectionTitle][subSectionTitle].theLabel.autoSize = true;
                _root.mainMenu[sectionTitle][subSectionTitle].theLabel.text = subSectionTitle;
                _root.mainMenu[sectionTitle][subSectionTitle].theLabel.setTextFormat(myformat);
                //
            }
            _root.mainMenu[sectionTitle]._y = totalHeight;
            totalHeight = totalHeight+_root.mainMenu[sectionTitle]._height;
        }
    } else {
        trace("error");
    }
    for (m=0; m<theLinks.length; m++) {
        theBtns[m].onPress = function() {
            getURL(this.myLink, "_blank");
        };
    }
    runIt();
};
menu_xml.load("menuItems.xml");
// --< function for collapsing and expanding the menu (by Senocular) >-- \\
function runIt() {
    var anim_frames = 4;
    var opened = null;
    var menus = [];
    FindMenus = function () {
        for (value in _root.mainMenu) {
            if (_root.mainMenu[value] instanceof MovieClip) {
                menus.push(_root.mainMenu[value]);
            }
        }
        menus.sort(SortByVertical);
    };
    SortByVertical = function (a, b) {
        return (a._y>b._y);
    };
    ApplyMenuMask = function (i) {
        var menu = menus*;
        var mask = this.createEmptyMovieClip("mask"+i, i);
        mask._x = menu._x;
        mask._y = menu._y;
        mask.beginFill(0, 100);
        mask.moveTo(0, 0);
        mask.lineTo(menu.title._width, 0);
        mask.lineTo(menu.title._width, menu.title._height);
        mask.lineTo(0, menu.title._height);
        mask.endFill();
        menu.setMask(mask);
        menu.masker = mask;
    };
    StartMenuPosition = function (i) {
        var menu = menus*;
        if (i == 0) {
            menu._y = menu.masker._y=0;
        } else {
            var menu_above = menus[i-1];
            menu._y = menu.masker._y=Math.round(menu_above._y+menu_above.title._height);
        }
    };
    MenuOpen = function () {
        var menu = this;
        menu.masker._height += (1+menu._height-menu.title._height)/anim_frames;
        if (menu.masker._height>=menu._height) {
            menu.masker._height = menu._height-1;
            delete this.onEnterFrame;
        }
        PositionMenusBelow(menu.i);
    };
    MenuClose = function () {
        var menu = this;
        menu.masker._height -= (1+menu._height-menu.title._height)/anim_frames;
        if (menu.masker._height<=menu.title._height) {
            menu.masker._height = menu.title._height;
            opened = null;
            menu.onClose();
            delete menu.onClose;
            delete this.onEnterFrame;
        }
        PositionMenusBelow(menu.i);
    };
    TitleButtonPress = function () {
        var menu = this._parent;
        if (opened) {
            if (opened == menu) {
                menu.onEnterFrame = MenuClose;
            } else {
                opened.onClose = function() {
                    menu.onEnterFrame = MenuOpen;
                    opened = menu;
                };
                opened.onEnterFrame = MenuClose;
            }
        } else {
            menu.onEnterFrame = MenuOpen;
            opened = menu;
        }
    };
    PositionMenusBelow = function (i) {
        var menu = menus*;
        if (i<menus.length-1) {
            var menu_below = menus[i+1];
            for (i=i+1; i<menus.length; i++) {
                if (menus* == menu_below) {
                    menus*._y = menus*.masker._y=menu._y+menu.masker._height;
                } else {
                    var menu_above = menus[i-1];
                    menus*._y = menus*.masker._y=menu_above._y+menu_above.masker._height;
                }
            }
        }
    };
    Init = function () {
        FindMenus();
        for (var i = 0; i<menus.length; i++) {
            menus*.i = i;
            ApplyMenuMask(i);
            StartMenuPosition(i);
            menus*.title.onPress = TitleButtonPress;
        }
    };
    Init();
}


I have one question which is very important. I have that xml file and what happened when some menu button doesn’t have a submenu? Something like that;):

  • Link 1
  • Link 2
    • Link A
    • Link B
  • Link 3
    • Link C
      etc. and I want that - when I am pressing on Link 1 something will happen - now is problem because url’s works only in submenus ;/ when I’m clicking on for example on Link 1 nothing happened;/ I have tried simple to paste into xml file something like that:

<?xml version="1.0" encoding="UTF-8"?>
<myMenu>
<menu title = "O firmie" **theurl = "index.php?action=aboutfirm&underaction=showaboutfirm"**></menu>
<menu title = "Ch&#322;odnictwo">
<menu Subtitle = "ch&#322;odnictwo1" theurl = "index.php?action=cooling&underaction=showcooling&id=1" /> 
</menu>
<menu title = "Gastronomia">
<menu Subtitle = "gastronomia1" theurl = "index.php?action=gastronomy&underaction=showgastronomy&id=1" />
</menu>
<menu title = "Meble">
<menu Subtitle = "meble1" theurl = "index.php?action=furniture&underaction=showfurniture&id=1" />
</menu>
<menu title = "Realizacje" theurl = "index.php?action=accomplishment&underaction=showaccomplishment" ></menu>
<menu title = "Promocje" theurl = "index.php?action=promotion&underaction=showpromotion" ></menu>
<menu title = "Kontakt" theurl = "index.php?action=contact&underaction=showcontact" ></menu>
</myMenu>


but as You see… it doesn’t work fine - it doesn’t work at all :stuck_out_tongue:
And one more question - how to make text ( which I am importing from xml file ) alligned to the right? default it is probably alligned to left.
sorry for this stupid question but it is really important for me:)