5 Replies Latest reply on Dec 21, 2012 2:50 PM by kglad

    Get rid of "undefined" word...

    Germaris Level 1

      Hi there!

       

      Simple question (but complex answer, maybe...):

      How to get rid of the word "undefined"  appearing in TextFields?

       

      Many thanks in advance for your replies!

        • 1. Re: Get rid of "undefined" word...
          kglad Adobe Community Professional & MVP

          assign a text string that's defined and don't assign a variable to the textfield.  for example:

           

          tf.text="";

          • 2. Re: Get rid of "undefined" word...
            Germaris Level 1

            Hi, kglad, thanks for replying.

             

            Problem is more complex that it seems...

            It's related to userName and userPass which could be stored in the ShareObject or not depending if the user chose to memorize them or not.

             

            var credentials:SharedObject = SharedObject("identifiers");

             

            If user chose to memorize them, I have no problem: I use getSize() to find if the ShareObject exists as it follows:

            credentialsExistFct = function () {

                var credentialsExist:Number = credentials.getSize("identifiers");

                if (credentialsExist > 0) {

                    userFld.text = userName;

                    passFld.text = userPass;

                }

            };

             

            If user chose not to memorize them in the previous session, the ShareObject has been deleted using clear() as follows:

             

            credentials.clear("identifiers");

             

            and then getSize() returns "undefined".

             

            At this the point, I'm stuck.

            How, in this case, can I instruct both fields (userFld and passFld) to be blank?

             

            -----------------------------------------------

            PS:

             

            A solution of my own could be, -when the user choose not to memorize the identifiers-, to assign a value ("a" for example) to both identifiers instead of using clear().

            This way, when reading the ShareObject (using getLocal()), the result will be "a" when using  this:

             

            credentials = SharedObject.getLocal("identifiants");

            var userName:String = credentials.data.userName;

            var userPass:String = credentials.data.userPass;

            if (userName = "a") {

                userFld.text = "";

            }

            else {

                userFld.text = userName;

            }

            if (userPass= "a") {

                passFld.text = "";

            }

            else {

                passFld.text = userPass;

            }

             

            What do you think?

            • 3. Re: Get rid of "undefined" word...
              kglad Adobe Community Professional & MVP

              use:

               

              credentials = SharedObject.getLocal("identifiants");

              var userName:String = credentials.data.userName;

              var userPass:String = credentials.data.userPass;

              if (!userName) {

                  userFld.text = "";

              }

              else {

                  userFld.text = userName;

              }

              if (!userPass) {

                  passFld.text = "";

              }

              else {

                  passFld.text = userPass;

              }

              • 4. Re: Get rid of "undefined" word...
                Germaris Level 1

                Thanks!!!

                Very simple...

                 

                Just in case we'll do not communicate before, I wish you to spend a beautiful Christmas and, of course, a wonderful year 2013!

                • 5. Re: Get rid of "undefined" word...
                  kglad Adobe Community Professional & MVP

                  you're welcome.

                   

                  (and, thank you!)