4 Replies Latest reply on May 10, 2008 11:16 AM by riesvantwisk

    Tab Component Not Updating (Bug?)

    Jaz Chana
      Wow. Just discovered the forums today and already making the most of them!

      Anyways, I've come across another problem possibly a bug. I have a parent component that makes a call to a server side component. On completion it dispatches a custom event. I've added listeners to 5 other components so that when they detect this event they all enable a corresponding button. These seven components are contained within a parent component that is in term contained within the first component.

      So it goes something like this; grandparent--->parent-->children. The grandparent dispatches the event and the children register listeners. In addition the children extend the box component and are wrapped around a tab navigator in the parent component.

      Now the problem is this. When the event is fired the children are supposed to enable the button (btn.enabled = true;). But it is only those components whose tabs that have been selected prior to the event being fired that are able to enabled the button. For example, if I click on Tab1 and Tab 2 (children 1 and 2) and THEN the event is dispatched, Tab1 and Tab2 will enable their buttons. However Tab 3 - 5 will not enable their buttons. Then if click on tab 3 and the event is again dispatched Tab3 will enable its button, but 4 and 5 will not.

      Its extremely strange and to be honest its doing my head in! LOL. Has anybody else had this kind of behavior? is this a bug that I am not aware of? Is there a solution or a possible workaround?

      Thank You
      Jaz
        • 1. Re: Tab Component Not Updating (Bug?)
          Gregory Lafrance Level 6
          When you declare your TabNavigator, set creationPolicy="all". By default it is creationPolicy="auto", which means contents of each tab do not exist until the tab is clicked. creationPolicy="all" creates all contents of all tabs at app startup.

          <mx:TabNavigator creationPolicy="all"/>
          • 2. Re: Tab Component Not Updating (Bug?)
            Jaz Chana Level 1
            Ahhhh creationPolicy!! I had a suspicion it would be something like that, so I created a method to loop through the tabs and disable and then enable them again thinking this would create the content. Funnily enough this worked for one random tab, but not all. Thank you very much for your reply. Invaluable. One more question, does turning on the creationPolicy cause some sort of performance issue?
            • 3. Re: Tab Component Not Updating (Bug?)
              Gregory Lafrance Level 6
              Startup time could be affected. See these FB3 help topics:

              Improving Startup Performance
              About the creationPolicy property
              • 4. Re: Tab Component Not Updating (Bug?)
                riesvantwisk Level 1
                May I remind you that we still have this great thing called DataBinding.

                What I am doing is it like this:
                (ro is remote Object with a specific function)
                <mx:Button enabled="{ro.myRemoteFunction.lastResult!=null}" .....>


                Or when you get some data collection back you store in a array collection, for example:

                [Bindable] private var myArray:ArrayCollection=new ArrayCollection();

                function myResult(event:ResultEvent):void {
                myArray = new ArrayCollection(event.result as Array);
                }

                <mx:Button enabled="{myArray.length>0}" .....>


                The above was done from the top of my head, but you get the idea...

                Use DataBinding!!!!

                Ries