catch GET variables in the page URL

7 posts

Flag Post

hi all,
to take the high scores and stuff on my games from php/mysql, i always used some POST vars generated by a php file. But now, i have to catch the GET vars in the url for another project and well … it doesn’t work and google didn’t help that much !

i have my page with a URL like http://www…./index.php?lang=fr
for example.
The only thing i want is catch the “fr” value inside flash.

I tried with something like :
___________________________________________________


var monChargement_lv = new LoadVars();
monChargement_lv.onLoad = function(success) {
if (success) {
score_max = monChargement_lv.lang;
}
};
monChargement_lv.load(“http://…index.php”, monChargement_lv, “GET”);

_____________________________________________________

but well, i get the super “undefined” value. if anyone got an idea, it would be great :D

thanks
pixtiz

 
Flag Post

Hi Pixtiz, the score_max var that you’re trying to set, is nested inside the local function, so that might be part of the problem. It might just be a scope issue. If max_score is at the root level, then from inside the local function, use the full path, root.maxscore. If that doesn’t work, let me know. I have some more documentation for you.

 
Flag Post

well i tried with a _root in fact but i didn’t want to have some “you used evil _root ahhhh” answers, i took it off. So, Rich, your documentation would be nice ;)

thanks

 
Flag Post

it seems like that it’s more something about loadVariablesNum but… i can’t make it work :’(

 
Flag Post

Here’s an example from the flash reference that I use. This method works for me everytime. It assumes that you’re sending and receiving vars from a serverside script. Notice that it uses POST not GET. Let me know if it doesn’t work…

    var result_lv:LoadVars = new LoadVars();
    result_lv.onLoad = function(success:Boolean) {
        if (success) {
            result_ta.text = result_lv.welcomeMessage;
        } else {
            result_ta.text = "Error connecting to server.";
        }
    };
    var send_lv:LoadVars = new LoadVars();
    send_lv.name = name_ti.text;
    send_lv.sendAndLoad("http://www.flash-mx.com/mm/greeting.cfm", result_lv, "POST");

 
Flag Post

thanks RP but in fact, i know how to use it with POST, i would do it like this if i could ^^. The thing is that i have to modify an existing script and get the ID (which is sent from a backlink an email) of the index.php (something like index.php?ID=2763sdfg) and i want to get this ID in the swf animation on the page.

flashvars directly in the page code may be a solution …

 
Flag Post

well i finally found the solution using flashvars (really simple) :)

thanks richpixel for your help ;)