11 Replies Latest reply on Oct 27, 2010 8:29 PM by Neat Gadget

    Dynamic Text Not Updating

    Neat Gadget

      I have some simple code that should update some dynamic text but it seems to be doing it out of order.

       

      function(){return A.apply(null,[this].concat($A(arguments)))}

      function loginAttempt() {
      _root.txt_progressbar.text = "Attempting to login, please wait...";
      var valid_login = _root.check_login(_root.txt_username.text,_root.tx t_password.text);
      if (valid_login == true) {
      mdm.Forms.Menu.setFocus();
      mdm.Forms.Menu.show();
      mdm.Forms.CTBCC.alpha=0;
      }
      }


      The txt_progressbar.text is not being updated until the function finishes.

        • 1. Re: Dynamic Text Not Updating
          kglad Adobe Community Professional & MVP

          what are you doing, what happens and what do you expect to happen?

          • 2. Re: Dynamic Text Not Updating
            Neat Gadget Level 1

            You will see the code above, and the line "Attempting to login etc..." Well that should display before any other code is executed, but it doesn't. It executes once the function finishes. The way I can tell this is because in the function call on line 2, there is a dialog prompt called which is displayed but the dynamic text has not changed. Once I click past the dialog, then the dynamic text is changed.

            • 3. Re: Dynamic Text Not Updating
              kglad Adobe Community Professional & MVP

              it executes before your function call on line 2.  but, if that function call does anything with the text property of your textfield, you may not see the text property change.

               

              if that doesn't help you solve your problem, copy and paste line 2 function code.

              • 4. Re: Dynamic Text Not Updating
                Neat Gadget Level 1

                here is the second function call code:

                 

                function(){return A.apply(null,[this].concat($A(arguments)))}

                function check_login(username,password) {

                btn_login.label = "Logging In";

                  if (_global.dbconnected & username != "") {
                  
                   _global.dbhost = "";
                   _global.dbport = "";
                   _global.dbcompression = "false";
                   _global.dbusername = username;
                   _global.dbpassword = password;
                   _global.dbname = "";
                  
                   _global.dbconnected = mdm.Database.MySQL.connect(_global.dbhost, _global.dbport, _global.dbcompression, _global.dbusername, _global.dbpassword, _global.dbname);
                   //mdm.Dialogs.prompt("_global.dbconnected: "+_global.dbconnected)
                /*   var login_sql="SELECT User, Password FROM mysql.user WHERE User='"+username+"'"    
                   var login_sql="SHOW TABLES"    
                   check_sql(login_sql,0);
                   mdm.Dialogs.prompt("ERROR MSG: " + mdm.Database.MySQL.getLastError());
                   var dataSet =  mdm.Database.MySQL.getData()
                   var field = mdm.Database.MySQL.getField(0, 0)
                   if (dataSet.length == 0) {*/
                   if (_global.dbconnected == false) {
                    mdm.Dialogs.prompt("Login details not correct, please try again.")
                    _root.gotoAndPlay("Login");
                   }
                   else {
                /*    _global.username = dataSet[0][0];
                    _global.password = dataSet[0][1];*/
                    _global.username = username;
                    _global.password = password;
                    mdm.Flash.setVar("CTBCC:dbconnected",_global.dbconnected);
                    mdm.Flash.setVar("CTBCC:username",_global.username);
                    mdm.Flash.setVar("CTBCC:password",_global.password);

                    return true;
                   }
                  
                }
                else
                {
                  mdm.Dialogs.prompt("Please enter a username.")
                  return false;
                }
                btn_login.label = "Login";
                btn_login.enabled = true;


                }


                As you can see this does not touch the dynamic text field at all.

                • 5. Re: Dynamic Text Not Updating
                  Neat Gadget Level 1

                  First line of the above code seems to be added by this website, so ignore it.

                  • 6. Re: Dynamic Text Not Updating
                    kglad Adobe Community Professional & MVP

                    there's probably enough going on in that function to lock-up your flash for a while.

                     

                    to remedy, don't call that function for a clock-tick:

                     

                     

                     

                    var tl:MovieClip=this;

                     

                    function loginAttempt() {
                    _root.txt_progressbar.text = "Attempting to login, please wait...";

                     

                    tl.onEnterFrame=delayF;

                    }

                     

                    function delayF(){

                    delete tl.onEnterFrame;
                    var valid_login = _root.check_login(_root.txt_username.text,_root.tx t_password.text);
                    if (valid_login == true) {
                    mdm.Forms.Menu.setFocus();
                    mdm.Forms.Menu.show();
                    mdm.Forms.CTBCC.alpha=0;
                    }
                    }

                    • 7. Re: Dynamic Text Not Updating
                      Neat Gadget Level 1

                      Thanks heaps, that worked!

                       

                      Just wondering if there is another way to code it so I could call a function with the string for the dynamic text, and it does the update, does the delay and moves on?

                      • 8. Re: Dynamic Text Not Updating
                        kglad Adobe Community Professional & MVP

                        you can pass that string to loginAttempt(), by using something like:

                         

                        loginAttempt(yourstring)

                         

                        and:

                         


                         

                         

                         

                        var tl:MovieClip=this;

                         

                        function loginAttempt(s:String) {
                        _root.txt_progressbar.text = s;

                         

                        tl.onEnterFrame=delayF;

                        }

                         

                        function delayF(){

                        delete tl.onEnterFrame;
                        var valid_login = _root.check_login(_root.txt_username.text,_root.tx t_password.text);
                        if (valid_login == true) {
                        mdm.Forms.Menu.setFocus();
                        mdm.Forms.Menu.show();
                        mdm.Forms.CTBCC.alpha=0;
                        }
                        }

                         

                        p.s.  please mark this thread as answered.

                        • 9. Re: Dynamic Text Not Updating
                          Neat Gadget Level 1

                          Thanks, that wasn't what I was meaning but I'll figure out the rest from here. Thanks very much for your help!

                          • 10. Re: Dynamic Text Not Updating
                            kglad Adobe Community Professional & MVP

                            you're welcome.

                            • 11. Re: Dynamic Text Not Updating
                              Neat Gadget Level 1

                              Ok, although the above solution works, I really need to have a better structure.

                               

                              I want to have a single function I can call to do the change of the txt_progressbar.text . Now I know how to do this, but I need to be able to do it in the context of this problem. ie ensuring the text is changed before the rest of the function is run.

                               

                              The above solution would require me to create a delay function everytime I wanted to change that text.

                               

                              Any ideas?