1 Reply Latest reply on Jul 4, 2006 7:22 PM by scribintoons

    Quirky LoadVars won't let me set Send variables in function

      So, my last host died at the beginning of the month and I just got everything migrated to a new host. I was trying to get back to work on this Flash project that logins via PHP to a mySQL database. The login script stopped working. I have discovered that _global.getcards.THISVARIABLE will not let me set THISVARIABLE, but this only happens from the login function. I can write a test function with copy/pasted code from the broken one and it will work. I am pretty sure this function worked before. If I copy/paste the whole function it breaks again, but the set data is at the beginning of the function, so I don't understand how that could change it. . .

      Here's the code that calls the script from the login button:

      on (release, keyPress "<Enter>") {
      . . .
      else if (emailbox.length>0 && passwordbox.length>0) {
      if (scriptbox.length>0){
      janeticookie.data.script = scriptbox.text;
      calledFromLoginButton = true;
      } . . .

      And the beginning of the PHPgetCards function:

      function PHPgetCards(s){
      //declare variables
      if (s == undefined)
      _global.getcards.SCRIPT = janeticookie.data.script;
      else if (s != "NULL")
      _global.getcards.SCRIPT = s;
      . . .
      _global.getcards.sendAndLoad(' http://mysite.com/getcards.php', _global.getcards, 'GET');
      _global.getcards.onLoad = function (success){
      if (success){
      . . .

      If I trace _global.getcards.SCRIPT and janeticookie.data.script, janeticookie (a shared object) works, but getcards (a LoadVars) comes back undefined. If I make a test function

      function testme(){
      _global.getcards.user_email = janeticookie.data.email;
      _global.getcards.user_password = janeticookie.data.password;
      and call it right before PHPgetCards in the login script, it traces properly. Any idea what's going on? Here are my variable declarations from the frame the login button occurs on:

      #include "copyright.as"
      #include "md5.as"
      #include "LphpAS.as" //the PHPgetCards function
      include "test.as" //the testme() function
      import it.sephiroth.Serializer;
      _global.serial = new Serializer();
      _global.getcards = new LoadVars();
      _global.newscript = new LoadVars ();
      _global.savescript = new LoadVars ();
      . . .
      _global.janeticookie = SharedObject.getLocal("janeticookie");

      Thanks much!
        • 1. Re: Quirky LoadVars won't let me set Send variables in function
          scribintoons Level 1
          So I just got back from a long weekend and I found the problem. Here is the code at the end of the function that handles how it exits (I faked indentation with backticks cause this forum deletes tabs):

          if(calledFromLoginButton == true){
          ` calledFromLoginButton = false;
          ` if(scriptcookie.data.user == undefined)
          ``` _root.gotoAndPlay('badlogin');
          ` if(scriptcookie.data.user != undefined)
          ``` _root.gotoAndStop('makePanels');
          }else if (calledFromTransition == true){
          ` trace("open");
          ` calledFromTransition = false;
          ` updateBigPanel();
          ` updatePanels();
          ` //_parent.play();
          } else{
          ` updateBigPanel();
          ` updatePanels();

          The commented _parent.play() breaks it. I don't understand why, because calledFromTransition is not true and based on the trace that code snippet is not being invoked by this function call (calledFromTransition is used in a later call). Can someone please explain why?