Use this[control label] to reference controls declared
![Use this[control label] to reference controls declared](http://www.java2s.com/Code/FlexImages/Usethiscontrollabeltoreferencecontrolsdeclared.PNG)
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
public function changeLabel(s:String):void {
s = "myButton" + s;
this[s].setStyle("fontStyle","italic");
this[s].setStyle("fontSize","18");
}
</mx:Script>
<mx:Button id="myButton1" click="changeLabel('2')" label="Change Other Button's Styles" />
<mx:Button id="myButton2" click="changeLabel('1')" label="Change Other Button's Styles" />
</mx:Application>
Related examples in the same category