6 Replies Latest reply on Jul 8, 2009 6:43 AM by kglad

    dynamic generated tabs from array, can't get incremented values for button action

    Bit Crusher

      Hi -

       

      Here's the setup:

       

      I have a basic array that has 6 values in it (i.e. the tab labels).

       

      The tabs are generated without a problem and when I view the objects all six show.  For example:

      Movie Clip: Frame=1 Target="_level0.tabsMC6"

       

      so that's cool.

       

      Now when I go to set up the button action for these babies, if I use the _level0.tabs.MC6 then sure, I can fire off button action(s) for that tab or any if I change the tabsMC value.  What I want to do is try to cut down on the code and have the tab value increment, but the best I've been able to achieve is having the last tab work.  The interesting thing is that if I try any of the other tabs (1-5) they all fire off tab #6.

       

      What I have right now is:

       

      function tabCount():Void{
          for (i=0; i<_root.slideContainerMC.tabList.length; i++) {
              _level0["tabsMC"+ i].clickerMC.onRollOver = function(){
              _level0["tabsMC"+ i].gotoAndStop("on");
              }
          }
      };

       

       

      (side note:  tabList is the array I mentioned above and yes, it is in another MC, which = code all over the place however I am in a rush)

       

      What I need for some guidance is how to get all of the tabs to have individual button actions.  I thought that the above script woul then have button actions for

       

      tabsMC1

      tabsMC2

      tabsMC3

      tabsMC4

      tabsMC5

      tabsMC6

       

      which it doens't do exactly.  tabsMC6 is the only tab that will show the "on"state - I can roll over any of them and that's the only tab that shows this rather than EACH tab showing a state.

       

      Seems like I'm missing the obvious!

       

      Thanks!

        • 1. Re: dynamic generated tabs from array, can't get incremented values for button action
          kglad Adobe Community Professional & MVP

          if  _level0.tabs.MC6 is a typical (correct) reference, use:

           

           

           

          function tabCount():Void{
              for (i=0; i<_root.slideContainerMC.tabList.length; i++) {

                 _level0.tabs[MC"+ i].ivar = i;  // <-- which you'll probably need at some point

                 _level0.tabs[MC"+ i].clickerMC.onRollOver = function(){
                      this._parent.gotoAndStop("on");

                  }
              }
          };

           

           

          (side note:  tabList is the array I mentioned above and yes, it is in another MC, which = code all over the place however I am in a rush)

           

          What I need for some guidance is how to get all of the tabs to have individual button actions.  I thought that the above script woul then have button actions for

           

          tabsMC1

          tabsMC2

          tabsMC3

          tabsMC4

          tabsMC5

          tabsMC6

           

          which it doens't do exactly.  tabsMC6 is the only tab that will show the "on"state - I can roll over any of them and that's the only tab that shows this rather than EACH tab showing a state.

           

          Seems like I'm missing the obvious!

           

          Thanks!

          • 2. Re: dynamic generated tabs from array, can't get incremented values for button action
            Bit Crusher Level 1

            cool - the syntax you had posted needed to be finessed (threw up some errors at first) so now it looks like:

             

            function tabCount():Void{
                for (i=0; i<_root.slideContainerMC.tabList.length; i++) {

             

                   _level0["tabsMC"+ i].ivar = i;

             

                   _level0["tabsMC"+ i].clickerMC.onRollOver = function(){
                        this._parent.gotoAndStop("on");
                    }
                   
                    _level0["tabsMC"+ i].clickerMC.onRollOut = function(){
                        this._parent.gotoAndStop("off");
                    }
                   
                    _level0["tabsMC"+ i].clickerMC.onRelease = function(){
                        this._parent.gotoAndStop("onPress");
                    }
                }
            };

             

            and yep, this works although tabs 1-5 now function properly, tab #6 is inactive.  Since the array length is six values (0-5) is this what's causing the last tab not to receive it's MC number?

             

            Another question that I do have from your code (thanks again by the way) - what does the

            _level0["tabsMC"+ i].ivar = i;

             

            produce?  the one part that's throwing me off is

            ivar = i;

             

            I don't think I've come across that and it's a bit confusing.

             

            Thanks again!

            • 3. Re: dynamic generated tabs from array, can't get incremented values for button action
              kglad Adobe Community Professional & MVP

              you're defining tabMC0,...,tabMC5.  if you want tabMC1,...,tabMC6 use:

               


               

              function tabCount():Void{
                  for (i=1; i<=_root.slideContainerMC.tabList.length; i++) {

               

                     _level0["tabsMC"+ i].ivar = i;

               

                     _level0["tabsMC"+ i].clickerMC.onRollOver = function(){
                          this._parent.gotoAndStop("on");
                      }
                     
                      _level0["tabsMC"+ i].clickerMC.onRollOut = function(){
                          this._parent.gotoAndStop("off");
                      }
                     
                      _level0["tabsMC"+ i].clickerMC.onRelease = function(){
                          this._parent.gotoAndStop("onPress");
                      }
                  }
              };

               

               

               

              and the ivar part was anticipating that you would need the ith tab to know it's the ith tab.  ivar stores the value of i used when that particular tabMC was created.  if you don't need that, remove it.

              • 4. Building editable lists
                jntt1211

                Dear friends , can you please tell me how to build a set of list boxes using the user interface components in flash . So that i can enter data into one and move that entered data to anther and send all the obtained data values to my database. A simple example of what i'm trying to acheive is shown below.

                Looking forward for your reply!

                 

                Thanks & Rgds

                jntt1211

                 

                listpicker.jpg

                • 5. Re: dynamic generated tabs from array, can't get incremented values for button action
                  Bit Crusher Level 1

                  Perfect!  I tried changing i=1 yesterday with the same results but by adding in that equal to or less than that did the trick...which makes sense.

                   

                  Thank you my friend for solving another problem!