11 Replies Latest reply on Apr 13, 2011 12:08 PM by kglad

    selection.setfocus

    Abakus07

      I am doing a form question with 6 layers, 1. Basically, 2.  button, 3. text, 4. input text ... etc. ... The questionnnaire takes several frames and depending on the answer I go to another frame gotoAndPlay (). I verify that the input fields are ok with a message in my statut_txt.text. When I start my movie and I click on the button (btn1), the first entry fields texte_prenom becomes dark, done by an action fonction and Selection.setFocus and it works but when I click on another field that I have completed and I click on the button, I made a mistake to texte_prenom fields is empty, I have the answer in my status which said complete first name, but the input text this time the input fields texte_prenom does not become dark and I am unable to leave the order input field I was with the mouse ...Problem with the cursor, AS2

       

       

      btn1.onRelease = function(){

       

      texte_prenom = texte_prenom.text;
      texte_nom = texte_nom.text;

       

      if (texte_prenom.length == 0){
      Selection.setFocus("texte_prenom");
      var text_font:Number = 0xef1005;
      status_txt.textColor = text_font;
      status_txt.text = "* Inscrire un prénom!";
      }
      else if (texte_nom.length == 0){
      Selection.setFocus("texte_nom");
      var text_font:Number = 0xef1005;
      status_txt.textColor = text_font;
      status_txt.text = "* Inscrire un nom!"; }

       

      else {
      if (ComboBox1_txt.text == "bungalow" && ComboBox2_txt.text =="non"){gotoAndPlay(2);
      }


      Somebody have idea?

        • 1. Re: selection.setfocus
          kglad Adobe Community Professional & MVP

          make sure both prenom and nom textfields are single line, non-html enabled textfields with kerning unchecked.

          • 2. Re: selection.setfocus
            Abakus07 Level 1

            I'm with no html and my input text field are to 1 line.

            Oder explication test... when I write in input textfield and I clic on the button, my cursor go very fast in my selection.setfocus but go very fast and stay only in the last input textfield I have write, impossible to do something else, the cursor stay here. In my form I have 3 combobox and when a change something in one of the combobox, after this, I,m able to change something in my all order input textfield, the cursor appears ok when I do this..

             

            I have this script to highlight my input text field, but I have erase this script for check and no change, my error stay here...

                var normal_border:Number = 0x000000;
                var focus_border:Number = 0x17f546;
                var normal_background:Number = 0xffffff;
                var focus_background:Number = 0x808080;
                var normal_color:Number = 0x000000;
                var focus_color:Number = 0x000000;
                inputs=[texte_prenom,texte_nom,texte_adresse,texte_ville,texte_codepostal,texte_telephone ,texte_courriel];
            for( var elem in inputs) {
              inputs[elem].border = true;
              inputs[elem].borderColor = normal_border;
              inputs[elem].background = true;
              inputs[elem].backgroundColor = normal_background;
              inputs[elem].textColor = normal_color;
              inputs[elem].onSetFocus = function() {
               this.borderColor = focus_border;
               this.backgroundColor = focus_background;
               this.textColor = focus_color;
               }
              inputs[elem].onKillFocus = function() {
               this.borderColor = normal_border;
               this.backgroundColor = normal_background;
               this.textColor = normal_color;
               }
              }
                    };

             

            tks for help...

            • 3. Re: selection.setfocus
              kglad Adobe Community Professional & MVP

              that last code snippet isn't setting focus.

              • 4. Re: selection.setfocus
                Abakus07 Level 1

                Hello!

                 

                I say my last code is ok, but I have realy a problem with the focus on my flash animation, I don't see where, I have try some code but no result....The selection.setfocus is ok when I clic on my button directly, but when I write text in one of the textfield and I clic on the button, the focus is no good....

                • 5. Re: selection.setfocus
                  kglad Adobe Community Professional & MVP

                  setfocus AFTER release on your button, no press.

                  • 6. Re: selection.setfocus
                    Abakus07 Level 1

                    The fonction() is on release the button...

                     

                    btn1.onRelease = function(){

                     

                    texte_prenom = texte_prenom.text;
                    texte_nom = texte_nom.text;

                     

                    if (texte_prenom.length == 0){
                    Selection.setFocus("texte_prenom");
                    var text_font:Number = 0xef1005;
                    status_txt.textColor = text_font;
                    status_txt.text = "* Inscrire un prénom!";
                    }
                    • 7. Re: selection.setfocus
                      kglad Adobe Community Professional & MVP

                      this isn't right:

                       

                      texte_prenom = texte_prenom.text;
                          texte_nom = texte_nom.text;

                       

                      you're (trying to) assign textfields to strings.

                      • 8. Re: selection.setfocus
                        Abakus07 Level 1

                        My problem is not the variable, my variable work great. My trouble is the focus after I have clic on the button when I have write in a order input text field before...

                         

                        texte_nom = texte_nom.text; for a text

                        and

                        texte_variable = Number(texte_variable.text); for a number

                         

                        Tks

                        • 9. Re: selection.setfocus
                          kglad Adobe Community Professional & MVP

                          you might think that's working great but flash doesn't.  after you do that you're trying to set focus on a string.

                          • 10. Re: selection.setfocus
                            Abakus07 Level 1

                            ok, I have replace this code... the var of my input text texte_prenom by prenom_txt and work good... My problem is what you said .. double variable string!

                             

                            btn1.onRelease = function(){

                            texte_prenom = prenom_txt.text;
                            texte_nom = nom_txt.text;
                            texte_adresse = adresse_ext.text;
                            texte_ville = ville_txt.text;
                            texte_codepostal = codepostal_txt.text;
                            texte_telephone = telephone_txt.text;
                            texte_courriel = courriel_txt.text;
                            texte_modele = ComboBox1_txt.text;
                            texte_garage = ComboBox2_txt.text;
                            texte_nbfenetretotal = Number(ComboBox19_txt.text);

                             

                            if (texte_nom == ""){
                               Selection.setFocus("nom_txt");
                               var text_font:Number = 0xef1005;
                               status_txt.textColor = text_font;
                               status_txt.text = "* Inscrire un nom!";
                               }
                               else if (texte_prenom == ""){
                               Selection.setFocus("prenom_txt");
                               var text_font:Number = 0xef1005;
                               status_txt.textColor = text_font;
                               status_txt.text = "* Inscrire un pr

                             

                            Tks

                            • 11. Re: selection.setfocus
                              kglad Adobe Community Professional & MVP

                              you're welcome.