We Recommend

Essential ActionScript 3.0 Essential ActionScript 3.0
The book focuses on the core language and object-oriented programming, but also adds a deep look at the centerpiece of Flash Player's new API: display programming. Enjoy hundreds of brand new pages covering exciting new language features, such as the DOM-based event architecture, E4X, and namespaces--all brimming with real-world sample code.


Posted By

justcaldwell on 11/12/07


Tagged

actionscript Flex as3 mxml


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

copyleft


Using a compound String to get a reference to Flex 3 object


Published in: ActionScript 3 


URL: http://livedocs.adobe.com/labs/flex3/html/help.html?content=usingas_3.html

Using a string built at runtime to reference objects in Flex. From the help docs.


  1. <?xml version="1.0"?>
  2. <!-- usingas/FlexComponents.mxml -->
  3. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  4. <mx:Script><![CDATA[
  5. public function changeLabel(s:String):void {
  6. s = "myButton" + s;
  7. this[s].setStyle("fontStyle","italic");
  8. this[s].setStyle("fontSize","18");
  9. }
  10. ]]></mx:Script>
  11.  
  12. <mx:Button id="myButton1" click="changeLabel('2')" label="Change Other
  13. Button's Styles"/>
  14. <mx:Button id="myButton2" click="changeLabel('1')" label="Change Other
  15. Button's Styles"/>
  16. </mx:Application>

Report this snippet 

You need to login to post a comment.