4 Replies Latest reply on Oct 5, 2006 6:23 AM by Mumboz

    LoadVars in a custom class

    Mumboz
      Hi

      What I need is basicly the following: A function, that sends a query to PHP and returns the result.

      What I have done so far is using LoadVars to send the query, and it is executed correctly since I can see the result in the database. The result is saved from the onLoad-function to a global variable. The problem is that the function, in which I use LoadVars, returns before onLoad has executed, and thus can't return the result of the query.

      Is there any way I can get my function to wait for the onLoad to complete?
      I have tried the dirty solution and made a simple while-loop, that runs while the loaded-variable is false, but that only causes it to lock up, and it never seem to get to the onLoad-function.

      I have attached the code i am are using.

      To sum up, what I need is a function, that can send a query to PHP and return a result.


      Thanks in advance for any help
        • 1. Re: LoadVars in a custom class
          coldMiner Level 1
          c.sendAndLoad("system/timetable.php", c, "POST");
          Hello I'm "c" and I am sending variables from me to php to me.
          What I need is a "d" that receives the variables php are sending, because I have soo much to do...
          var d = new LoadVars(); // add
          c.sendAndLoad("system/timetable.php", d, "POST"); // change
          d.onLoad = getResult; //change
          • 2. Re: LoadVars in a custom class
            Mumboz Level 1
            Im affraid that didn't make any difference and the original problem still persists.
            • 3. Re: LoadVars in a custom class
              coldMiner Level 1
              Of course the function returns before the onLoad completes...
              You have to use something like this:
              • 4. LoadVars in a custom class
                Mumboz Level 1
                Just wanted to come with an update:

                It doesnt seem possible to solve this problem in Flash with the way LoadVars is currently working.

                Seaching on Google and various forums has come up with no solution at all.
                The only "solution" that I can see is dropping most of my class structure in Flash and code more directly towards PHP, which is not a good solution in any way.

                Edit: Thanks for the answer coldMiner. I will look into it, but even though it might work, it's not the solution I had hoped for :-(