PDA

View Full Version : Format of variables sent from PHP


Steep Freaks
05-15-2006, 11:06 AM
Hi All

In the past I have found it unnecessary to post by simply making use of the search feature because virtually every question I can think of has been asked before. In this case I cannot find an answer either here or on phpfreaks or tizag. I am using Flash 5, if that makes a difference here?

My question is this: What format is a variable in when it comes from PHP to flash?

The background is this: I am having PHP evaluate if a cookie is set and then set a variable in flash. Flash then needs to evaluate that if the variable is set then it needs to load a movie into level 3.

The debugging is this: I have tested the PHP and it returns &language=yes. From there I put a dynamic text box on the stage with the variable _level0.language and the text box displays yes when loaded from the server. It also does not display yes when the cookie is not loaded. So I know flash is getting the variable, I know the variable is only set when the cookie is. I have tried adding and removing the quotes around "yes" and adding and removing spaces and even changing it to != and none of that has changed anything. I have been able to get the cookieset.swf to load by simply loading it so I know my path and everything to that are correct.

I now need to be able to evaluate if the language variable is set or if is equal to or not equal to a given value.

I have included all the pertinent code below (I think):

This is what I want to do: (not working)

loadVariablesNum ("/test/cookieset.php", 0);
if (_level0.language == "yes") {
loadMovieNum ("cookieset.swf", 3);
}

cookieset.php contains this:

<?php
if($_COOKIE['language'] == "english"){
include_once "cookieset2.php";
}elseif($_COOKIE['language'] == "french"){
include_once "cookieset2.php";
}elseif($_COOKIE['language'] == "german"){
include_once "cookieset2.php";
}elseif($_COOKIE['language'] == "italian"){
include_once "cookieset2.php";
}elseif($_COOKIE['language'] == "spanish"){
include_once "cookieset2.php";
}else
?>

and cookieset2.php contains this:

<?php
echo "&language=yes";
?>

I would appreciate no smart-ass comments on my horrible syntax, as I suck at writing code and typically end up debugging and patching things together. For example I know I can use isset rather than all the elseif statements but it seems to work better and I'm not sure if I have to use the include_once but flash seemed to not read it properly otherwise.

Thanks very much for taking the time to read my unnecessarily long post and any and all help is much appreciated.

Steep Freaks Gear

Steep Freaks
05-15-2006, 12:47 PM
Hi
Thanks for taking the time but I have this problem sorted out now. I would still appreciate any comments people may have because I do not understand why it is working.

I moved the if statement to _level2 were the dynamic text field was located and that is when I got it working. The only way it works is by is by doing:
if (_level0.language != ""){ etc. So I am still not calling the right variable I'm just filling the variable with something.

Thanks again

Steep Freaks Gear
Outdoor Gear to Elevate Your Heart

bassplaya
05-19-2006, 10:30 AM
it needs time to load data from server

Steep Freaks
05-25-2006, 01:21 PM
Thanks very much for the help, it took me a bit to figure that out. At first I was thinking it must be loading in time if my script was working but I think I must have been lucking out becuase after doing some more tests I realized it does take a second for the text to show up in the dynamic textbox. So I moved the the if statement down to the end of the timeline on layer 0 and it works just fine.

Thanks again,
Steep Freak