PDA

View Full Version : How to access dynamically placed buttons



danar
November 25th, 2007, 02:00 PM
I am having a lot of trouble figuring out how I am going to access these buttons outside of the function which created them. If someone wouldn't mind showing me how that would be great.

Even if someone could simply write a separate function that would trace the text on any of the buttons that would show me what i need to know.

Thanks in advance.

download fla (http://www.roberts-racing.com/test/test.fla)


//BUTTON IN LIBRARY HAS LINKAGE NAME btn


function setBtn():void{
var myBtn:btn;
for(var i:Number=0;i<20;i++){
myBtn=new btn();
this.addChild(myBtn);
myBtn.name="btn"+String(i);
myBtn.y=i*15+(i*2);
myBtn.txt.text = "stop"+i;
myBtn.index=i;
myBtn.alpha=0.7
trace(myBtn.txt.text);
}
}

setBtn();

oaki
November 25th, 2007, 03:36 PM
trace( getChildByName( "btn1" ) );

danar
November 25th, 2007, 03:58 PM
trace( getChildByName( "btn1" ) );


Thanks so much, I appreciate it!