Jump to content

Actionscript & Flash with PHP : php varibales collected in flash DEFY the if - then functionality.


ajoo

Recommended Posts

Hi to all gurus, 

Here is a small program in flash which calls values from PHP and displays them correctly. 

 


path = "http://localhost/xampp/nwjv/php/"; //declare path to php files
lvOut = new LoadVars(); //create lv object sending variables OUT to php
lvIn = new LoadVars(); //create lv object receiving variables IN from php


lvIn.onLoad = function (success) {
if(success)
{
//PHP variable value to textbox

InVal = lvIn.returnVal;
InTxt = lvIn.retVal;

output.text = InVal;
output1.text = InTxt;


/* output1.text = "No Value";

if(InTxt == 'lo' )
{
output1.text = "Low Value";
}

if(InTxt == 'hi')
{
output1.text = "High Value";
}
*/
}else{
//...or notify of failure
output.text = "fail";
}
}



myBtn.onRelease = function(){
//assign user-input value to lv property called years
lvOut.years = years.text;
//send to a blank window
// lvOut.send(path + "dogyears_new1.php",lvIn,"GET");
lvOut.sendAndLoad(path + "dogyears_new1.php",lvIn,"GET");
};

 

And the simplest PHP code

 

PHP Code:
<?php$calculation $_GET["years"]*2
if(
$calculation <=10 $retVal="lo"
if(
$calculation 10)  $retVal="hi"
echo 
"&returnVal=$calculation &retVal=$retVal;?>




PHP returns two values which are collected by flash in variables InVal and InTxt. The values collected are correct and are displayed thus in the 2 output boxes. 

Now if i the commented out If then block is activated by removing the /* */ from around it and the program is run, clearly the if then blocks fail since the comparison of InTxt fails. It completely fails me why this is happening. While I can display the values correctly, I can't use them in conditional loops. I have even tried them in switch case statements with the same frustrating result. ( The output1.text remains equal to "No Value" when it should change to either "High Value " or "Low Value")

Earlier I was using numbers and when that failed I tried to use strings since I thought that for some reason PHP returns everything as strings. Please note that  the command typeof InTxt (not used in the above code) returns a String suggesting that InTxt is a string variable.

 

But as can be seen, even the string comparison fails. 

Can someone please comment on this behavior and suggest a solution. 
Thanks loads all !

Link to comment
Share on other sites

Hi all, 

 

Well this seems to be the most slow moving part of the forum and maybe rightly so because it's basically a php forum.

Anyways I have managed to solve this one. Will come back with some more flash problems and hope that I will get some pointers if not solutions.

 

Thanks all !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.