Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-11-2009
Member
 
Join Date: Nov 2009
Posts: 45
sendAndLoad does not return under flash

I have a little communication problem php -> flash.

I have a SWF with 2 text fields that I have appointed vlogin and vpassword and a button named loginbutton

I then send the information to the button with php script with this:

HTML Code:
loginButton.onRelease = function()
{
var a_send:LoadVars = new LoadVars();
var a_receive:LoadVars = new LoadVars();
a_receive.onLoad = function (success:Boolean)
{
 if(success)
 {
  if (this.value == "bad" )
  {
   _root.gotoAndStop(3);//here the text field without a name with the variable value must show bad
  }
  else (this.value == "good" )
  {
   _root.gotoAndStop(2);//here the text field without a name with the variable value must display good
  }
 }
 else
 {
  _root.gotoAndStop(4);// msg:error 
 }
};
a_send.login = vlogin.text;
a_send.password= vpassword.text;
a_send.sendAndLoad("script.php", a_receive, "POST" );
};
my php page (tested with an HTML form) sent me the good news

PHP Code:
<?php
include('connect.php');
if(
$_POST['login'])
{
$login = ($_POST['login']);
$password = ($_POST['password']);
  
$sql "select password from pwmaj where login='".$login."'";
  
$req mysql_query($sql) or die('Error SQL !<br>'.$sql.'<br>'.mysql_error());
  
$datamysql_fetch_assoc($req);
  if(
$data['password'] != $password)
  {
   echo 
"value=bad";
  }
  else
  {
echo 
"value=good";
  }
}
?>
The problem is that I didn't receive anything in flash and whatever happens good or bad login it pushes the return on the frame 2 that normally appears only if the return is "good" and its empty not good in the field ..

no news for movie clip:
Layer 1 img 1 field and button + script
Layer 2 & 3 img 2 & 3 return field with var: value
Layer 3 img 4 error message
Reply With Quote
  #2  
Old 18-11-2009
Member
 
Join Date: Nov 2008
Posts: 1,192
Re: sendAndLoad does not return under flash

I think that PHP does not return what awaits in Flash ...

Your code is wrong (it is because of the tolerance of AS2 what did not error), because you have half instead of else if else making it the default condition, so it can go over the important issues ...

Otherwise, in PHP, use this syntax: echo "&value=good& "; // echo "&value=bad&";
Reply With Quote
  #3  
Old 18-11-2009
Member
 
Join Date: Nov 2008
Posts: 996
Re: sendAndLoad does not return under flash

1. If you are not testing online, you need WAMP and call your PHP file so http://localhost/myfolder/script.php
2. Your AI is very bad.

You do not use _root and you have to populate your text fields by giving them a name occurrence with this syntax:
myField_txt.text = myVar;

This enables you to debug the code. You can test your code like this.
You create a dynamic text field "DEBUG".
Then:

a_receive.onLoad = function (success:Boolean){
if(success){
DEBUG.text = this + " - my value : " + this.value;
}
}
Reply With Quote
  #4  
Old 18-11-2009
Member
 
Join Date: Nov 2009
Posts: 45
Re: sendAndLoad does not return under flash

Thank you for the info with it I'm sure it's good!

For AS I am coding only since last 2 weeks and flash has been a month since I use it and I'm not one to begin by reading the basic although I regret it often!

Little question "You do not use _root" I should put anything to run the general scene instead of _root?

And the "debug" I'll get more info I do not understand what has too matches the + or -

And this + "- my_value" is the name of the variable that receives the variable in php?
Reply With Quote
  #5  
Old 18-11-2009
Member
 
Join Date: Nov 2008
Posts: 996
Re: sendAndLoad does not return under flash

Quote:
Little question "You do not use _root" I should put anything to run the general scene instead of _root?
You can have a function like
a_receive.onLoad = function (success:Boolean){
if(success){
treatSendAndLoad(this)
}
}

function treatSendAndLoad(targ){
trace(targ.value);
}

Quote:
And the "debug" I'll get more info I do not understand what has too matches the + or -
The debug is my way of naming debugging. It allows you to listen to what's happening in your code. You come variables in a text field to understand the results of operations.

Quote:
And this + "- my_value" is the name of the variable that receives the variable in php?
While not all.

At the beginning of your code, you write this
var a_receive: LoadVars = new LoadVars ();
and end
a_send.sendAndLoad ( "script.php" a_receive, "POST");

This means that the data returned by PHP will fit in the object "a_receive.
When you do
a_receive.onLoad = function (success: Boolean) {
if (success) {
DEBUG.text = this + "- my value:" + this.value;
}
}

"this" is your subject "a_receive". By posting this (as here in a text field) you can see everything it contains. So sometimes the error messages from PHP, if you have sent for it coded.

Moreover, this line
DEBUG.text = this + "- my value:" + this.value;

If you want to display the message "hello world", you'll do it this way
trace("hello world" );

If you want to display plus another thing (say a random number and size of your scene) syntax is this:
trace("hello world " + Math.random() + Stage.width)

It will give you something like "hello world 0.23365 640"
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "sendAndLoad does not return under flash"
Thread Thread Starter Forum Replies Last Post
Can I return Ipad2 for new one? Kaesav Portable Devices 1 13-03-2012 06:48 PM
Cannot return to monitor standby after fullscreen with adobe flash Takhbir Windows Software 5 25-06-2011 05:58 AM
SSH return function Elizabeth Allen Networking & Security 5 22-04-2010 02:38 PM
How to use return() in PHP? Leoniee Software Development 5 06-03-2010 05:32 AM
KB923789 Flash fails - patch for flash v6.0 complains about Flash JG Windows Update 6 20-04-2007 11:44 PM


All times are GMT +5.5. The time now is 03:48 PM.