4 Replies Latest reply on Dec 24, 2007 11:34 AM by Newsgroup_User

    Flash 8 login showing strange behaviour

    John983289
      I am developing a Flash 8 login for my website but the problem is once loaded I fill in my credentials and press login....

      It only recieves the password and not the username (alert box used to show this) and once first attempt is over I try again and nothing is alerted - something to do with caching?

      Anyway here is the actionscript 2 that I believe is causing the problem:
      import flash.external.ExternalInterface;

      var callJS = new Object();
      btn_ok.addEventListener("click",callJS);

      callJS.click = function(evt: Object)
      {
      //create a new LoadVars object
      myvars = new LoadVars();
      //set variables in the object
      myvars.user = txt_login.text;
      myvars.pass = txt_password.text;

      ExternalInterface.call("Login", user, pass);
      }

      Thanks anyone
        • 1. Re: Flash 8 login showing strange behaviour
          kglad Adobe Community Professional & MVP
          user and pass are undefined in the code you showed so nothing useful should be passed to your javascript function.
          • 2. Re: Flash 8 login showing strange behaviour
            John983289 Level 1
            Of course oops.

            Well this is my latest attempt with the help of a tutorial (tutorial not using AJAX though, PHP):

            import flash.external.ExternalInterface;

            btn_ok.onRelease = function()
            {
            var myLogin:String = txt_login.text ;
            var myPassword:String = txt_password.text ;

            maVariable = new LoadVars();
            maVariable.var_login = myLogin ;
            maVariable.var_password = myPassword;

            maVariable.onLoad = function()
            {
            if ( maVariable.allow == 1)
            {
            getURL("index.php");
            }
            else
            {
            txt_result.text = "Login/Password incorrect";
            }

            }
            ExternalInterface.call("Login", maVariable)
            }

            This gives a weird error i.e. it refers to code I did not know existed. Anyway this is wrong as the AJAX will have to recieve two variables (username and password) not one (maVariable). Or maybe AJAX can split the maVariable and then use it?

            Cheers
            • 3. Flash 8 login showing strange behaviour
              John983289 Level 1
              I tried to make the maVariable, maVariable.toString and that actually allowed the AJAX to alert something - but this was the wrong thing i.e. [object Object]. Maybe there is a JS function that can read this type of object?

              This was the error earlier by the way if anybody is interested:
              Error: missing ] after element list
              Source Code:
              try { __flash__toXML(Login([type Function])) ; } catch (e) { "<undefined/>"; }
              • 4. Re: Flash 8 login showing strange behaviour
                Level 7
                AJAX? Flash and Ajax are kind of the same in a way, you really wouldn't use
                them together... You are trying to use a LoadVars object but issuing no
                sendAndLoad, instead you use externalInterface which you wouldn't do using
                LoadVars. You certainly can't send a LoadVars object to a javascript on your
                web page. I think you are going about this all wrong. Have a look at the
                sendAndLoad method of the LoadVars class in the Help and forget about ajax
                and externalInterface if you're trying to send some variables to a php
                script.

                --
                Dave -
                Head Developer
                http://www.blurredistinction.com
                Adobe Community Expert
                http://www.adobe.com/communities/experts/