let's say I have a variable in PHP and I need to echo it in AS2, how to do that?
<?php
$var = "variable";
?>
I need the ActionScript 2 code to connect to that PHP file, take the var $var and echo it. Thanks!
let's say I have a variable in PHP and I need to echo it in AS2, how to do that?
<?php
$var = "variable";
?>
I need the ActionScript 2 code to connect to that PHP file, take the var $var and echo it. Thanks!
Just echo
it with &
! You will get it inside the AS2
<?php
$var = "I will go inside AS2";
echo "&AS2Var=$var&";
?>
Here is an example
var post_obj:LoadVars = new LoadVars();
var result_obj:LoadVars = new LoadVars();
// when PHP respond....
result_obj.onLoad = function(success:Boolean) {
if (success) {
trace('from PHP : ' + result_obj.fromPHP + ' / fromAS : ' + result_obj.fromAS);
} else {
trace('error...');
}
};
// define some params to pass to PHP
post_obj.fromAS= "Hello from AS";
// call PHP script, when its done, onLoad event of result_obj will trigger
post_obj.sendAndLoad("/path/to/my/script.php", result_obj);
script.php
<?php
echo "&fromAS=PHP received : " . $_POST['fromAS'];
echo "&fromPHP=PHP did this at ".date("Y-m-d H:i:s")."&";
?>
This will output in Flash
from PHP : PHP did this at 2013-11-26 20:47:02 / fromAS : PHP received : Hello from AS