Código do menu
carregaXML = new XML();
carregaXML.ignoreWhite = true;
carregaXML.onLoad = function(sucesso) {
if (sucesso) {
var qtd = this.firstChild.childNodes.length;
var pos_x = 0;
for (var i = 0; i/*<*/qtd; i++) {
//aqui vai até o nó menu
var raiz = this.firstChild.childNodes[i];
//duplicando o mc 'textMenu' dentro do mc 'menuMc'
menuMc.textMenu.duplicateMovieClip("textMenu"+i,i+1);
//atribuindo a varialvel 'alvo' o corrente target
alvo = menuMc["textMenu"+i];
//no xml listaMenu - menu - titulo
alvo.titulo.htmlText = raiz.childNodes[0].lastChild.nodeValue;
//no xml listaMenu - menu - Link
alvo.Link = raiz.childNodes[1].lastChild.nodeValue;
//incrementando a posição do alvo _x
alvo._x += pos_x;
//'pos_x' mais a largura do texto +30
pos_x += alvo.titulo.textWidth+30;
//o bt ficar da largura do texto +7
alvo.bt._width = alvo.titulo.textWidth+7;
}
//como não uso o primeiro mc 'textMenu' eu escondo
textMenu._visible = false;
} else {
//se de erro no carregamento do xml
trace("ERRO NO XML");
}
};
carregaXML.load("menu.xml");
Botão
on (release) {
trace(this.Link+" - _x:"+this._x);
}
XML
Veja a demo Baixe o souce