1 Reply Latest reply on Oct 20, 2010 10:59 PM by Shongrunden

    Better way to access nested groups?

    mike_morales Level 2

      Hey all,


      I have a spark Panel, and within that panel a couple of spark Groups.  I want to dynamically populate these groups based on certain conditions. However, even though I have id's attached to all my groups, it seems I cannot access them directly with my code. example:


      . . .
      var tempTextInput:TextInput = new TextInput();

      tempTextInput.text = 'text here';

      group2.addElement(tempTextInput); // this generates errors


      <s:Panel id="myPanel">

           <s:Group id="group1" />

           <s:Group id="group2" />



      that doesn't work;

      It 'does' work when I go the 'long' way around by instantiating a Group and setting it to the group element of the panel like so;


      var tempGroup:Group = myPanel.getElementAt(myPanel.getNumElements-1) as Group;


      // this adds my content to the appropriate are on the panel


      There's got to be a better way to do this.  Do these 'nested' groups become properties of the panel and thus would have to be accessed through dot notation? I tried myPanel.group1.addElement but got an error.


      Any help is greatly appreciated, thanks!



        • 1. Re: Better way to access nested groups?
          Shongrunden Adobe Employee

          You should be able to access them directly, for example this works fine:

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"


                      private function init():void {
              <s:Panel id="myPanel">
                  <s:Group id="group1" />
                  <s:Group id="group2" />


          Try creating a small application like the one above that demonstrates the issue you are seeing so we can investigate further.