Jump to content


Photo

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

variables from flash ajoo

  • Please log in to reply
2 replies to this topic

#1 ajoo

ajoo

    Advanced Member

  • Members
  • PipPipPip
  • 194 posts

Posted 10 August 2014 - 11:28 PM

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 !



#2 ajoo

ajoo

    Advanced Member

  • Members
  • PipPipPip
  • 194 posts

Posted 11 August 2014 - 08:49 AM

Hi all,

 

Please find the relevant php and fla files for the above problem zipped in the attached file. Really looking forward to some reply, help, suggestion, solution to this problem.

 

Thanks all !

 

Attached Files



#3 ajoo

ajoo

    Advanced Member

  • Members
  • PipPipPip
  • 194 posts

Posted 19 August 2014 - 05:26 AM

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 !






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com