5 Replies Latest reply on Aug 3, 2007 9:19 PM by kglad

    LoadVars() + target window?

    1starks05
      I have a login form that I'm using inside my flash header banner of my site. The login uses LoadVars() and the send(url, "POST") type of thing to send the username and password to an ASP page. THe login works great, and even comes back to the page posting a "invalid username/password" when it's not working properly. If I get a successful login, and it loads up the actual page, it opens a new window to do that. Is there a way to keep it from opening a new window, and just have it stay on the same page, like a normal login would do? I know you can typically do target="_blank" when you do a getURL type of thing in flash. Is there way to do a target (would it be target="_parent"?) inside the .send for LoadVars()?

      This is the code for the send portion, for the most part:

      var login_lv:LoadVars = new LoadVars();
      login_lv.emailTextBox = emailTextBox.text;
      login_lv.passwordTextBox = passwordTextBox.text;
      login_lv.send("login.aspx", "POST");
      return true;

      It has some eventhandlers at the top, for when you click and it runs the function, etc. Anyone have idea how to keep all this stuff inside the same window when using LoadVars
        • 1. Re: LoadVars() + target window?
          kglad Adobe Community Professional & MVP
          what's causing a window to open?
          • 2. Re: LoadVars() + target window?
            1starks05 Level 1
            That's a very good question. I'm using a variation of the login form template that comes with flash mx 2004, and I really didn't change all that much. This is the complete actionscript. I don't recognize anything in here that would be forcing a new window to open...

            import mx.controls.*;

            var status_lbl:Label;
            var emailTextBox:TextInput;
            var password_ti:TextInput;

            /* Define a click handler for the submit_btn Button instance,
            which calls the checkForm function (defined below). */

            submit_btn.onRelease = function () {
            checkForm();
            };

            var formListener:Object = new Object();
            formListener.enter = function(evt) {
            checkForm();
            };
            emailTextBox.addEventListener("enter", formListener);
            password_ti.addEventListener("enter", formListener);

            Selection.setFocus(emailTextBox);

            function checkForm() {

            if (emailTextBox.text.length == 0) {
            status_lbl.text = "<font color=\"#FFCC00\"><strong>Incorrect Login/Password</strong></font>";
            Selection.setFocus(emailTextBox);
            return false;
            }
            if (password_ti.text.length == 0) {
            status_lbl.text = "<font color=\"#FFCC00\"><strong>Incorrect Login/Password</strong></font>";
            Selection.setFocus(password_ti);
            return false;
            }
            status_lbl.text = "";
            var login_lv:LoadVars = new LoadVars();
            login_lv.emailTextBox = emailTextBox.text;
            login_lv.passwordTextBox = password_ti.text;
            login_lv.send("login.aspx", "POST");
            return true;
            }
            • 3. Re: LoadVars() + target window?
              1starks05 Level 1
              Is it possible to put target="_window" or target="_parent" somewhere in the send portion of LoadVars?

              something to the equivalent of:
              login_lv.send("login.aspx", "POST", "_window");
              • 4. LoadVars() + target window?
                klintonray
                with LoadVars' send method the the syntax is

                public send(url:String, target:String, [method:String]) : Boolean

                so to do what you want, you would use:
                login_lv.send("login.aspx", "_self");

                you could also use:
                ("login.aspx", "_self", "POST")
                if you would like, but the method parameter is optional and it defaults to POST anyway.
                • 5. Re: LoadVars() + target window?
                  kglad Adobe Community Professional & MVP
                  there's nothing in the actionscript causing a window to open. it must be in your aspx code.

                  and you can specify the window that will receive that response as mentioned by klintonray. or you might want to use sendAndLoad() and use another loadvars object to receive your aspx'es response.