I’m trying to make dynamic menu using xml data, I’m creating that menu using loops
Here is my code
for (var i:int = 0; i < iloscWpisow; i++)
{
_guzik=new guzikIK();
_guzik.guzikIK_Over.alpha=0;
_guzikTekst = new TextField();
_guzikTekst.x = _tekstX;
_guzikTekst.y = _tekstY;
_guzikTekst.selectable = false;
_guzikTekst.width = _tekstSzerokosc;
_guzikTekst.height = _tekstWysokosc;
/*_guzikTekst.embedFonts = true;*/
tekst.color = 0xFFFFFF;
/*tekst.font = _arialRounded.fontName;*/
tekst.size = 18;
_guzikTekst.defaultTextFormat = tekst;
_guzikTekst.text = xml.children()[i]. tytul;
_guzik.addChild(_guzikTekst);
_guzik.x=32;
_guzik.y=_tekstPolozenie*i+55;
_guzik.buttonMode=true;
_guzik.mouseChildren = false;
_guzik[id]=i;
_menu.addChild(_guzik);
_guzik.addEventListener(MouseEvent.MOUSE_DOWN, klik);
And the problem is each button has the same id at the end, i need different id’s for each butt so it can be recoginzed.
It’s difficult to tell what exactly you’re asking, but the approach I would take would be to store all your buttons in an array and then refer to the buttons by their index in the array. Something like: