Bueno, ya encontre la solucion, espero que a alguien mas le sirva.
creacion de botones dinamicos mediante un xml.1)crea un movieclip en el escenario llamado "MyBtn", exportalo para actionscript con el mismo nombre de identificador; Dentro de el, crea un Textfield dinamico con nombre de instancia "buttonTitle_txt".
Suponiendo que este sea el archivo xml:
file.xml<?xml version="1.0"?>
<root>
<item id="1" buttonTitle="1" buttonLink="http://www.flash-genie.de" xpos="362.6" ypos="447.6" ancho="21.6" alto="48.2"/>
<item id="2" buttonTitle="2" buttonLink="http://www.flashmxfiles.com" xpos="344.1" ypos="447.6" ancho="18.4" alto="48.2" />
<item id="3" buttonTitle="3" buttonLink="http://www.actionscript.org" xpos="325.2" ypos="447.6" ancho="18.8" alto="48.2" />
<item id="4" buttonTitle="4" buttonLink="http://www.mambers.com" xpos="306.7" ypos="447.6" ancho="18.6" alto="48.2" />
</root>
Dentro del primer frame de la pelicula inserta el sig codigo:
//create a new XML object
myXML = new XML ();
//tell flash to ignore all the whitespace
//Ommiting this nearly always causes silly problems
myXML.ignoreWhite = true;
//when the xml has loaded
myXML.onLoad = function (success) {
//if we are successful, call our parse function (parseIt)
if (success) {
parseIt (this);
} else {
//Otherwise inform the user that an error has occured
//Probably our fault
trace ("Sorry, error loading XML files for the menu");
getURL ("javascript: alert('Sorry, error loading XML files!')");
}
};
//OK first bit done, its loaded (we will assume successfully..lets create objects from each bit now:
function parseIt (what) {
//Create an object for each "item"
_root.noOfKids = what.firstChild.childNodes.length;
//Note: We start at 0 with our loop
for (var i = 0; i < noOfKids; i++) {
_root["menuEntry" + i] = new Object ();
//Now we have them we need to create some properties of said items
//referring to the title and link of our button.
//The best way imo of doing this is to use attributes like such
_root["menuEntry" + i].buttonTitle = what.firstChild.childNodes[i].attributes["buttonTitle"];
_root["menuEntry" + i].buttonLink = what.firstChild.childNodes[i].attributes["buttonLink"];
_root["menuEntry" + i].xpos = what.firstChild.childNodes[i].attributes["xpos"];
_root["menuEntry" + i].ypos = what.firstChild.childNodes[i].attributes["ypos"];
_root["menuEntry" + i].ancho = what.firstChild.childNodes[i].attributes["ancho"];
_root["menuEntry" + i].alto = what.firstChild.childNodes[i].attributes["alto"];
//And thats it for that bit, normally we would attach our buttons and assign them their name and title here
//For ease of reading we will however call a function that does that like this:
assignBtnStuff ();
}
}
myXML.load ("file.xml");
/*
4)All thats left now is to make it all viewable by the user, we can check to see if all is good by using the debugger (Shift, ctrl + enter) after pressing the green arrow to commence we select _level0 and can see our objects under variables...All there? Good lets crack on, I'm getting hungry. As noted before we now need a function...so lets create one
*/
function assignBtnStuff () {
for (var i = 0; i < noOfKids; i++) {
_root.attachMovie("myBtn","XMLbtn"+i,i);
_root["XMLbtn" + i].buttonTitle_txt.text = _root["menuEntry" + i].buttonTitle;
//Lets position them vertically at 50px intervals starting at pixel 30
_root["XMLbtn" + i]._y = _root["menuEntry" + i].ypos;
_root["XMLbtn" + i]._x = _root["menuEntry" + i].xpos;
_root["XMLbtn" + i]._width = _root["menuEntry" + i].ancho;
_root["XMLbtn" + i]._height = _root["menuEntry" + i].alto;
//Our buttons need to link when pressed, to this end we need to make a note of their increment (i)
_root["XMLbtn" + i].incr = i;
_root["XMLbtn" + i].onRelease = function () {
//get _rootMenuEntry1 thru to the number of buttons we have...and check buttonLink
//which we assigned during parsing
getURL (_root["menuEntry" + this.incr].buttonLink, "_blank");
};
}
}
Y esto da como resultado diversos botones en el escenario, como veran desde el xml jala el ancho, alto, coordenadas en 'x' y 'y'. Esto es en caso de que sea necesario que cada boton sea diferente (como en mi caso).
Espero les sirva como ami...
Saludos!!!
Amed Rdz