Topic: LoadVariables doesn't get response

Hallo,

i want get one variable back from my PHP script to my chumby.

With

LoadVariables("http://www.server.com/getvar.php?id="+id, _root, "GET");
textfeldname.text = _root.fromphp.text;

But the text field 'textfeldname' shows "undefined" after i execute the script.

The PHP script is being called, because it sends an email with each request and it also gets the parameter from the chumby.

Can you please tell me, how the syntax for LoadVariables ('_root', 'level0', 'this' ????) must be, or an alternative for getting variables from PHP back to chumby ?

Thank you very much !!!
driess

Re: LoadVariables doesn't get response

Loading variables from the network is an *asynchronous* process.  Flash does not block until it completes - so the values will not be available on the next line of code.

"loadVariables" is a somewhat deprecated way to load stuff since it doesn't support handlers and you effectively need to poll for completion - instead you should probably use the LoadVars class.

Re: LoadVariables doesn't get response

Hallo Duane,

thank you very much for the information.

Is there anything i have to regard when working with LoadVars on the chumby ?

Do you have any example that works ?

Best regards,
driess

Re: LoadVariables doesn't get response

There's nothing special for the chumby - it's standard Flash.

There are simple examples in the "help" section of the Flash IDE - look for "LoadVars" and then "onLoad".

A good Google search to try is "+LoadVars +onLoad" - a lot of tutorials and examples show up.

Re: LoadVariables doesn't get response

Hallo Duane,

O.K., i've got it.

For anyone interested, here's a possible solution:

on (press ) {
    var serverPath = "http://www.server.com/flaform_wt.php";
        
    //get data
    var getData = new LoadVars();
    getData.load(serverPath + "?chumby_id_fetch=" +_root["_chumby_chumby_id"] );
    getData.onLoad = function(success){
        if(success){
           
            some_textfield.text = this.FromPHP;
        }
        else{
            some_textfield.text ="data didn't load";
        }
    }
}

Have a nice weekend,
driess