Jump to content

Archived

This topic is now archived and is closed to further replies.

hack4lk

PHP/FLASH/sendAndLoad - PLEASE HELP!!!!

Recommended Posts

Hi everyone....I have spent the last day trying to figure this problem out but cannot find what it is....I cannot send vars to php...but I can receive them in flash as echos from php....I am using sendAndLoad to send the vars to php....here is the code.

[b]::Flash::[/b]
var sendData:LoadVars = new LoadVars();
sendData.myVar1 = "11111";
sendData.myVar2 = "impact";
sendData.sendAndLoad("test2.php", sendData, "POST");

[b]::PHP::[/b]
$myVar1 = $_POST['myVar1'];
$myVar2 = $_POST['myVar2'];
echo $myVar2;


Thanks for any advice in advance.

Share this post


Link to post
Share on other sites
Here's an example (actionscript function):

function loadwhatever(){
var objSend:LoadVars = new LoadVars();

/*Values to be sent (id) */
objSend.id = '1';

/*Send variable to php and load the variables*/
objSend.sendAndLoad(whatever.php+"?nocache=" + Math.random(), objSend, "POST");

/*When the results are loaded into flash - add this*/
objSend.onLoad = function(ok) {

//do something here
}
}

In my experience you should force flash to not cache the results. Otherwise when you're testing you won't see he changes you made to the code.

On the php side everything seems fine.

Share this post


Link to post
Share on other sites
Works great but I had to change the send string to:
objSend.sendAndLoad("whatever.php?nocache=" + Math.random(), objSend, "POST");

Share this post


Link to post
Share on other sites

×

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.