I'm having a bit of a problem on getting to know what button was pressed, or at least convert that info into a number.
Here's what I want to do:
STAGE-------->fundo(movieclip)-------->botao(button)
I have a for cycle displaying the fundo movieclip in rows and collumns, so that the images and text that are inside the fundo movieclip can repeat. But there's also a button so when I click, something different happens for each movieclip. The thing is that I want to be returned a number for each movieclip. All I got on trace untill now is "_level0.fnd6.botao", but the only info that I want is "fnd6", or only "6", if that's possible. Is there a way to get that?
This is the button function:
Code:
linha.botao.onRelease = function(){
trace(this);
for (i=0; i<totalitems; i++){
//with this I remove all movieclips already on stage
_root["fnd"+i].removeMovieClip("fnd"+i);
}
};
And, if you need to check the rest of the code:
Code:
System.useCodepage = true;
var MeuXML:XML = new XML();
MeuXML.ignoreWhite = true;
MeuXML.onLoad = function(sucesso)
{
xpos = 20;
ypos = 20;
vspace = 26;
hspace = 46;
altura = 200;
largura = 160;
contlinhax = 0;
contlinhay =0;
if (sucesso)
{
totalitems = MeuXML.firstChild.childNodes.length;
for (i=0; i<totalitems; i++)
{
img = MeuXML.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
nomebaila = MeuXML.firstChild.childNodes[i].attributes.id;
linha = fundo.duplicateMovieClip("fnd"+i, _root.getNextHighestDepth());
linha.mcvazio.loadMovie(img, _root.getNextHighestDepth());
linha.nome.text = nomebaila;
linha.botao.onRelease = function(){
trace(this);
}
linha.botao.onRelease = function(){
trace(linha.nome.text);
for (i=0; i<totalitems; i++){
_root["fnd"+i].removeMovieClip("fnd"+i);
}
};
linha._x = (xpos-10)+((largura+hspace)*contlinhax);
contlinhax++;
linha._y = (ypos-10)+((altura+vspace)*contlinhay);
if (contlinhax == 5){
contlinhay++;
contlinhax = 0;
}
}
}
else
{
trace(sucesso);
trace("Ocorreu um erro ao carregar os dados.");
}
};
MeuXML.load("bailar.xml");
stop();