1 Reply Latest reply on Jan 6, 2010 9:21 PM by Gregory Lafrance

    how to reference a variable through another variable?

    BosDog Level 1

      say I have 2 Flex label components. one with the id = "flexComponent1" and the other "flexComponent2"

       

      how would i (using actionscript) refer to one or the other without strong typing it?

       

      something like this:

       

      var test:String = "flexComponent1";

      test.text = "hello";

       

      And I want the actual label of flexComponent1 to change to "hello"

        • 1. Re: how to reference a variable through another variable?
          Gregory Lafrance Level 6

          Maybe this:

           

          <?xml version="1.0" encoding="utf-8"?> 
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="init();">
            <mx:Script>
              <![CDATA[
                private function init():void{
                  var test:* = flexComponent1;
                  test.text = "hello";        
                }      
              ]]>
            </mx:Script>
            <mx:Label id="flexComponent1"/>
          </mx:Application>
          

           

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services