2 Replies Latest reply on Aug 23, 2007 10:10 AM by neopium

    Extending TabNavigator

    neopium Level 1
      Hi everyone ! :)

      I need to extend the TabNavigator class in order to display a tab bar containing :
      - tabs on the left (as usual)
      - a button the user can click on the right
      Of course, my button should stay on the right of the tab bar whatever the size of the TabBarNavigator

      I didn't want to start from scratch, so I had a look at FlexLib and its great SuperTabNavigator. However, my tabNavigator is much more simpler than the SuperTabNavigator and I just wanted to extend one class : TabNavigator. I tried this :


      quote:

      package extensions
      {
      import mx.containers. TabNavigator;
      import mx.controls. TabBar;
      import mx.controls. tabBarClasses. Tab;
      import mx.core.mx_internal ;
      import mx.core.IFlexDispla yObject;
      import flash.display. DisplayObject;
      import mx.controls. Button;
      import mx.containers. HBox;
      import mx.containers. Canvas;
      import mx.controls. Spacer;

      use namespace mx_internal;

      public class extended_TabNavigat or extends TabNavigator
      {

      protected var holder:HBox;

      protected var spacer:Spacer;

      protected var myButton:Button;

      public function extended_TabNavigat or()
      {
      super();
      }

      override protected function createChildren( ):void{

      // Tab bar creation
      tabBar = new TabBar();

      super.createChildre n();

      // Holder that will contain my tab bar, a spacer and the button
      holder = new HBox();

      // Adds the container to the TabNavigator
      rawChildren. addChild( holder);

      // Adds the TabBar to the holder container
      holder.addChild( tabBar);

      // Spacer that will fill the space between the tabs and the button
      spacer = new Spacer();
      spacer.percentWidth = 100;

      // Adds the spacer to the container
      holder.addChild( spacer);

      // My button
      myButton = new Button();
      myButton.label = "Hello world !";

      // Adds the button to the container
      holder.addChild( myButton) ;


      }
      }
      }


      So I created an HBox containing:
      - the tab bar
      - a spacer filling all available space
      - and my button

      Unfortunately, it doesn't work... The TabNavigator has no tab bar nor button...

      Do you have any idea why ?

      Thanks a lot