/ Published in: ActionScript 3
Using a string built at runtime to reference objects in Flex. From the help docs.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?xml version="1.0"?> <!-- usingas/FlexComponents.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script><![CDATA[ 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>
URL: http://livedocs.adobe.com/labs/flex3/html/help.html?content=usingas_3.html