3 Replies Latest reply: Oct 23, 2007 8:12 AM by Karl_Sigiscar_1971 RSS

    Need an event that fires for child containers on tabnavigator change

    BIOSMonkey
      I have a tabnavigator with canvas containers representing pages in a web app. What event can I attach to each canvas container's implementation actionscript file that will fire whenever that canvas comes into view via the tab selection? (sort of like an onload event). This event is used to refresh data for that particular page, so I need it to fetch data whenever the page (tab) is selected.

      I do not want to attach any events to the tabnavigator itself so that the implementation is generic at the container level. I tried several events, such as show and creationComplete, but the creationComplete event only fires the first time when the canvas is instantiated.

      Maybe this is really easy and I am just missing it somehow...
        • 1. Re: Need an event that fires for child containers on tabnavigator change
          atta707 Community Member
          show should be called on the canvas each time that tab for the canvas is selected. so should the updateComplete.

          have you tried that?

          ATTA
          • 2. Need an event that fires for child containers on tabnavigator change
            BIOSMonkey
            "show" is the first thing I tried, but it will only fire if the canvas is shown after coming from another sibling (ie another tab or link in the same navigation control).
            I created a small test file here:
            http://webpages.charter.net/brandonmb/files/test.mxml
            that uses a linkbar inside a tabnavigator. In my regular application, the linkbar is actually another tabnavigator, but this demonstrates why I don't want to attach any events to the navigation control.

            You will note that the first link under each main tab has a show event defined. This will only fire if you click another sibling, then come back to it.

            I need an event to fire ANY time the canvas (ie the content of each subtab) comes into view, for whatever reason. This event will trigger code to fetch and refresh data on the page.

            You would intuitively think that "show" would do just this, but it doesn't (unless I am doing something wrong). It should fire, for example, when the user clicks the main tab, and the first tab is selected by default. It should also fire if I click the same link it is currently on (but I think this has to do with the fact that Flex disables the current link for some reason, instead of showing it as a 'selected' color).
            • 3. Need an event that fires for child containers on tabnavigator change
              Karl_Sigiscar_1971 Community Member
              <mx:Script>
              <![CDATA[

              private function onTabChanged(event:IndexChangedEvent):void
              {
              switch(event.newIndex)
              {
              case 0:
              // Do someting for the first tab
              break;
              case 1:
              // Do someting for the second tab
              break;
              case 2:
              // Do someting for the third tab
              break;
              default:
              // And so on and so forth...
              }
              }

              ]]>
              </mx:Script>


              <mx:TabNavigator id="tabNavigatorMain"
              change="onTabChanged(event)">
              </mx:TabNavigator>