14 Replies Latest reply on Nov 29, 2012 10:41 AM by kglad

    tI

    Ron Colmen Level 2

      I've got 5 text fields in _root.mc1, and 2 text fields in _root.mc2 and 10 text fields on the root. all are sitting in the same frame.

       

      1. How do I set tabIndex to each of those to cycle in each movieclip or root, depending on where the user starts typing?

       

      2. How do I add onKeyDown=function() if there is a button in each movie clip and on the root? (Assuming LEFT arrow is assigned for both movieclip buttons and for the button on the root, how can I make only one active at a time)

        • 1. Re: tI
          kglad Adobe Community Professional & MVP

          1.

           

          var tIndex:Number = 1;

           

          for(var i:Number=0;i<5;i++){

          _root.mc1["tf_"+i].tabIndex=tIndex++;

          }

          for(i=0;i<2;i++){

          _root.mc2["tf_"+i].tabIndex=tIndex++;

          }

          for(i=0;i<10;i++){

          _root["tf_"+i].tabIndex=tIndex++;

          }

           

          2.  what's the keydown listener supposed to do?

          1 person found this helpful
          • 2. Re: tI
            Ron Colmen Level 2

            Thank you Kglad.

             

            2.  an onRelease();

            • 3. Re: tI
              kglad Adobe Community Professional & MVP

              you want a keydown event to trigger a some object's onRelease?

               

              if yes, do different keys trigger different object's onRelease?

              • 4. Re: tI
                Ron Colmen Level 2

                Thank you Kglad.

                • 5. Re: tI
                  kglad Adobe Community Professional & MVP

                  is your question about keydown answered?

                  • 6. Re: tI
                    Ron Colmen Level 2

                    like this?

                     

                    keyListenerNew = new Object();

                    keyListenerNew.onKeyDown=function(){

                       if(Key.isDown(Key.LEFT)){

                          _root.submit_btn.onRelease();

                       }

                    }

                    Key.addListener(keyListenerNew);

                    • 7. Re: tI
                      Ron Colmen Level 2

                      I tried what you suggested. But still the tabINdex order is moving incorrectely.

                       

                      i.e. if the cursor is in _root.mc1.tf1, 2nd tab moves to _root.mc2.tf2 ?

                       


                      1st in _root.mcvar tIndex:Number = 1;

                       

                      for(var i:Number=0;i<5;i++){

                      _root.mc1["tf_"+i].tabIndex=tIndex++;

                      }

                      for(i=0;i<2;i++){

                      _root.mc2["tf_"+i].tabIndex=tIndex++;

                      }

                      • 8. Re: tI
                        kglad Adobe Community Professional & MVP

                        6>  yes

                         

                        7>  check the names of your textfields.  if they match, that code will work.

                        1 person found this helpful
                        • 9. Re: tI
                          Ron Colmen Level 2

                          var tIndex:Number = 0;

                          var tf1:Array =[_root.tt.a, _root.tt.b, _root.tt.c];

                          for(i=0;i<tf1.length;i++){

                                    //tf1[i].tabIndex.tvas = i;

                          tf1[i].tabIndex=tIndex++;

                          trace (tIndex)

                          }

                           

                           

                          var tf2:Array =[_root.ttt.b, _root.ttt.a, _root.ttt.c];

                          for(i=0;i<tf2.length;i++){

                                    //tf1[i].tabIndex.tvas = i;

                          tf2[i].tabIndex=tIndex++;

                          trace (tIndex)

                          }

                           

                          I'm still unable to tab only inside _root.tt or only inside _root.ttt?

                          It index all text fields 1 - 6 and it tabbs in both movieclips. I want to tab only inside one mc at a time?

                           

                          //what I'm expecting is to be able to do this;

                          _root.tt.a.tabIndex = 1

                          _root.tt.b.tabIndex = 2

                          _root.tt.c.tabIndex = 3

                           

                          _root.ttt.b.tabIndex = 1

                          _root.ttt.a.tabIndex = 2

                          _root.ttt.c.tabIndex = 3

                          • 10. Re: tI
                            kglad Adobe Community Professional & MVP

                            you expect tabbing to ignore all the textfields in tt or in ttt?

                            • 11. Re: tI
                              Ron Colmen Level 2

                              When a user is on typing inside tt - ttt tabIndex should be ignored

                              (when on ttt, tt tabIndex should be ignored)

                              • 12. Re: tI
                                kglad Adobe Community Professional & MVP

                                use:

                                 

                                for (i=0; i<tf1.length; i++) {

                                    tf1[i].onChanged = changeF;

                                }

                                for (i=0; i<tf2.length; i++) {

                                    tf2[i].onChanged = changeF;

                                }

                                function changeF(tf:TextField):Void{

                                    if(memberOf(tf1,tf)){

                                        for (i=0; i<tf1.length; i++) {

                                            tf1[i].tabIndex = i;

                                        }

                                        for (i=0; i<tf2.length; i++) {

                                            tf2[i].tabIndex = null;

                                        }

                                    } else {

                                        for (i=0; i<tf2.length; i++) {

                                            tf2[i].tabIndex = i;

                                        }

                                        for (i=0; i<tf1.length; i++) {

                                            tf1[i].tabIndex = null;

                                        }

                                    }

                                }

                                 

                                function memberOf(a,e):Boolean{

                                    for(var i:Number=0;i<a.length;i++){

                                        if(a[i]==e){

                                            return true;

                                        }

                                    }

                                    return false;

                                }

                                1 person found this helpful
                                • 13. Re: tI
                                  Ron Colmen Level 2

                                  Thank you Kglad.

                                  • 14. Re: tI
                                    kglad Adobe Community Professional & MVP

                                    you're welcome.