Posted By

justcaldwell on 11/12/07


Tagged

actionscript Flex as3 mxml


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

copyleft
THEPWN3R


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  

Comments

RSS Icon Subscribe to comments
Posted By: test1234 on September 10, 2010

Awesome.....Thanks for the example....saved my time.

You need to login to post a comment.