View Full Version : Comparing received value
MaestroS
03-16-2008, 05:29 PM
I got following code:
stop();
button2.visible = false;
lvOut = new LoadVars();
lvIn = new LoadVars();
lvIn.onLoad = function (success) {
if(success)
{
if (lvIn.returnVal=="yes")
{
message.text = "Unable to create profile with provided data.";
}
if (lvIn.returnVal=="no")
{
button.visible = false;
button2.visible = true;
message.text = "You can create profile with this data!";
}
}
else
{
message.text = "Interaction failed!";
}
}
button.onRelease = function()
{
lvOut.user = user.text;
lvOut.pass = pass.text;
lvOut.sendAndLoad("creation/step1.php", lvIn, "POST");
};
The question is:
Why I can't check like that, what's been returned?
PHP returns only string values yes or no, but it seems that flash check it in different way.
So, how ?
the binary
03-16-2008, 06:15 PM
what shows a trace of 'lvIn' in the onLoad-handler,
and how is your returned string formated.. ?
cheers
MaestroS
03-16-2008, 06:32 PM
I don't know, what's this `trace`, but I can answer on your second question.
PHP returns values as follow:
<?
require_once('../class.php');
$game = new Game;
if ($game->Account->Exists($_POST['user'], $_POST['pass'])) {
$msg = "yes";
}
else {
$msg = "no";
}
echo "&returnVal=".$msg;
?>
var checking:String = lvIn.returnVal;
if(checking=="yes"){...ect
MaestroS
03-16-2008, 07:31 PM
Uhm...
@ASWC
I put your part of code, so now it looks:
stop();
button2.visible = false;
lvOut = new LoadVars();
lvIn = new LoadVars();
lvIn.onLoad = function (success) {
if(success)
{
var checking:String = lvIn.returnVal;
if (checking == "yes")
{
message.text = "Unable to create profile with provided data.";
}
else if (checking == "no")
{
button.visible = false;
button2.visible = true;
message.text = "You can create profile with this data!";
}
}
else
{
message.text = "Interaction failed!";
}
}
button.onRelease = function()
{
lvOut.user = user.text;
lvOut.pass = pass.text;
lvOut.sendAndLoad("creation/step1.php", lvIn, "POST");
};
but now nothing displays after inserting data in "message" window...
the binary
03-16-2008, 07:59 PM
try this and post the output ... pls..
lvIn.onLoad = function (success)
{
if (success)
{
trace('success')
trace(' '+ lvIn.returnVal);
}
else
{
trace('error');
}
}
cheers
MaestroS
03-16-2008, 08:06 PM
http://img503.imageshack.us/img503/5740/firstdf7.jpg
Directly from Flash.
but I solved the problem.
I used beloved "switch" statement:
switch(checking)
{
case "yes":
message.text = "You cannot create profile with this name.";
break;
case "no":
button.visible = false;
button2.visible = true;
message.text = "You can create profile with this data!";
break;
default:
message.text = checking;
break;
}
and it works!
I don't know what was going on with IF, but SWITCH worked.
Thank you guys for help!
#EDIT II
But why the hell this doesn't work ?
http://img265.imageshack.us/img265/3718/secondvn6.jpg
even with nextScene(); ?!
Scene 2 does appear for 1 milisecond and dissapears, showing first scene :o
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.