5 Replies Latest reply on Feb 26, 2010 1:49 PM by BosDog

    calling an id in flex programmatically with actionscript

    BosDog Level 1

      hi... i have a question that will most likely be a simple syntax fix.

      in the past i've successfully been able to reference an id of a component and its properties via actionscript using a variable... so say for instance a textbox component has an id = 'txtBox_2'... i could refer to this textbox and its properties without strong typing and by using this in actionscript:

       

      initApp="test(2)";

       

      public function test(useID):void{

      this["txtBox_"+useID].text

      }

       

      but i'm having trouble going deeper than that... say for instance i have a component inside of a component... in this case i'm trying to call 2 component levels down from my main.mxml file

       

      in main.mxml i have a component with an id of comp1

       

      in comp1 i have another component called comp2

       

      in comp2 i have function called loadData();

       

      i figured in main.mxml i could run that function by altering the code above like this:

       

      this

       

      ["comp1."+"comp2"].loadData();

       

      but i'm getting the error that flex can't find that ID. can someone help?

       

      Thanks!