8 Replies Latest reply on Sep 30, 2010 2:39 PM by Devtron

    TabNavigator firstTab style is never set, why?

    Devtron Level 3

      Hello,

       

      I have a TabNavigator control that I dynamically color and display.

       

      Subeesh helped me figure this out, in this thrread:

      http://forums.adobe.com/message/3139011

       

      ^ But if you notice, the first tab is never colored.

       

      Here is a newer screenshot of the problem:

      TabNavigator--firsttab-bad.png

      ^ As you can see the first tab is not colored, even though it is assigned a color in the code below:

       

      var tab:mx.controls.Button;
      tab = tn.getTabAt(i);
      tab.id = tab.label;
      tab.name = tab.label;
      tab.label = "";
      tab.visible=true;
      tab.includeInLayout=true;
      tab.setStyle("chromeColor", _colors[i]);

       

       

      Is there a different Style property that I need to set for firstTab, or for selectedTab? other than chromeColor?

      I am unsure what styles are available and am having a hard time tracking that down in Adobe documentation.

       

      Any ideas why the code does not color the first tab???

        • 1. Re: TabNavigator firstTab style is never set, why?
          Devtron Level 3

          Since all I hear is crickets chirping, I went ahead and "hacked" this with a form, with visibilty set to false as my first button.

           

          Not impressed with that at all but it works. But it really messes up my indexes on my arrays and referenced objects....

          • 2. Re: TabNavigator firstTab style is never set, why?
            Subeesh Arakkan Level 4

            try this in your css file  .

             

            mx|TabNavigator {
                        first-tab-style-name:"";
                        last-tab-style-name:"";
                        tab-style-name:"";
                    }

            1 person found this helpful
            • 3. Re: TabNavigator firstTab style is never set, why?
              Devtron Level 3

              well, Im not using CSS here. Can I reference those through A/S?

              • 4. Re: TabNavigator firstTab style is never set, why?
                Subeesh Arakkan Level 4

                tn.setStyle("firstTabStyleName","");


                                tn.setStyle("lastTabStyleName","");
                                tn.setStyle("tabStyleName","");
                • 5. Re: TabNavigator firstTab style is never set, why?
                  Devtron Level 3

                  Wow!! This works:

                   

                  tn.setStyle("firstTabStyleName","");

                   

                  But it introduces a new problem for me....the button widths do not get set, even if I explicitly set them.

                   

                  In my code I have:

                  tab.width= tn.width / distinctStringUsedForNumberOfTabs.length;

                   

                  ^ but the tab buttons disregard that.

                   

                  I have moved the logic around for setting the firsttab style, to before processing the buttons, and to after processing the buttons, but I still cannot seem to adjust their widths. Any ideas?

                  • 6. Re: TabNavigator firstTab style is never set, why?
                    Subeesh Arakkan Level 4

                    tn.setStyle("firstTabStyleName","");
                    tn.setStyle("lastTabStyleName","");
                    tn.setStyle("tabStyleName",""); 
                    for( var i:int = 0 ; i< 4 ; i++)
                    {
                        tn.getTabAt(i).setStyle("chromeColor", 0xff0000);
                        tn.getTabAt(i).width = (i+1) * 50;
                        tn.validateNow();
                    }

                    1 person found this helpful
                    • 7. Re: TabNavigator firstTab style is never set, why?
                      Devtron Level 3

                      It works for all buttons except the first one. The first button is evil.

                       

                      Here is the result:

                      TabNavigator--firsttab-bad.png

                       

                      Here is my code:

                      tn.setStyle("firstTabStyleName","");

                       

                      for (var i:int=0; i < 26; i++){

                                          var tab:mx.controls.Button;
                                          tab = tn.getTabAt(i);
                                          tab.id = tab.label;
                                          tab.name = tab.label;

                                          tab.label = "";
                                          tab.visible=true;
                                          tab.includeInLayout=true;
                                          tab.width=tn.width / distinctDayMap.length;

                                          tab.setStyle("chromeColor", _colors[i]);
                                          tn.validateNow();

                      }

                       

                       

                      ValidateNow() is cool stuff. Thanks for pointing that out. Do you know how to get the first button to behave correctly?

                      • 8. Re: TabNavigator firstTab style is never set, why?
                        Devtron Level 3

                        Ok I figured it out, all thanks to Subeesh. Actually, he figured it out. What a legend!

                         

                        Here is my code:

                        tn.setStyle("firstTabStyleName","");

                        tn.validateNow();

                         

                        for (var i:int=0; i < 26; i++){

                                            var tab:mx.controls.Button;
                                            tab = tn.getTabAt(i);
                                            tab.id = tab.label;
                                            tab.name = tab.label;

                                            tab.label = "";
                                            tab.visible=true;
                                            tab.includeInLayout=true;
                                            tab.width=tn.width / distinctStringUsedForNumberOfTabs.length;

                                            tab.setStyle("chromeColor", _colors[i]);

                        }

                         

                         

                        Good work! This works really great and looks super cool!