3 Replies Latest reply on Oct 18, 2010 2:32 PM by mike_morales

    Dynamically add content to nested navigators?

    mike_morales Level 2

      Ran into a roadblock and need some help from you experts. I have a TabNavigator nested inside of an AccordionNavigator and I would like to dynamically add content to the nested TabNavigator.

       

      I have given them all IDs but I cannot for the life of me, seem to target these NavigatorContent groups and add anything to them dynamically. It's driving me NUTZ!  I tried hardcoding some Groups within the navigatorContent's to try to target the Groups rather than the navigatorContent areas, but still no luck. Is this possible?

       

      Here is an image of what I'm describing. In the image, I am trying to dynamically add content to "tabNav1".  I tried the following:

      1)  tabNav1.addElement("CONTENT"); // ERROR

      2)  (tabNav1 as NavigatorContent).addElement("CONTENT"); // ERROR

      3)  (tabNavigator.selectedIndex(0) as NavigatorContent).addElement("CONTENT"); // ERROR

      4)  and so many other things, I've lost track!!

       

      They all return a "cannot access a property or method of a null object ref" error.

       

        ANY help will be GREATLY apprecited, thanks in advance!

       

       

      OR, if anyone knows what 'property' of the Accordian, or TabNavigator is used to set the "NavigatorContent"  class to? I tried to find the property in the livedocs, but couldn't  seem to find it.  That way I can just create all the navigators in pure  Actionscript, and not have to mess with the mxml tags.

       

      Please help before I toss my computer out the window! LOL.

       

      Mike

        • 1. Re: Dynamically add content to nested navigators?
          Devtron Level 3

          Hi,

           

          I use forms in my tabNavigator:

                          <mx:TabNavigator id="tabNavigator"
                                            creationPolicy="all"
                                            styleName="myTabStyle"
                                            click="selectProfile()"
                                            >

                               <mx:Form id="A" label="A" name="very blue" hideEffect="{hideEffect}"  showEffect="{showEffect}" visible="false" >
                                   <mx:Label text="Point" />
                                   <mx:NumericStepper id="PointA" name="PointA"  minimum="0" maximum="120" styleName="numStepper" color="white" />   
                               </mx:Form>

                       </mx:TabNavigator>

           

           

          This is how I access the form and add values to my UI controls:

           

                                  //find child controls dynamically
                                  var formObj:Object = tabNavigator.getChildAt(i);
                                  var formPoint:Object = formObj.getChildByName("Point" + "A");

                                  formPoint.value = 55;

           

           

          I hope this can help put you towards the right direction. This was not easy and tabNavigator is not my friend.

          1 person found this helpful
          • 2. Re: Dynamically add content to nested navigators?
            mike_morales Level 2

            Hi Devtron,

             

            Thanks for you suggestion/solution.  Prior to seeing your suggestion, I started to just extend some group classes, and build my own cuz I just cannot get it to work. It shouldn't be this difficult to add data to one of these containers. I will try your suggestion, thanks again.

             

            Mike

            • 3. Re: Dynamically add content to nested navigators?
              Devtron Level 3

              The "fun" is guessing what child objects are in the TabNavigator. I feel that my example above isn't that great but it's all I've got and it works. I wish I had better control over embedded/nested UI objects. Using the debugger to figure out what's available is not ideal. Good luck and if you have more questions let me know and I will help you the best I can. I've only worked in FLEX for 3-4 months now and have run into some brick walls like this. Cheers!