I have never had a problem passing variables from PHP to flash until now. The difference is that I’m trying to pass an IP Address.
Action Script 3:
var url:String = “http://localhost:8888/TheTest.php”;
var request:URLRequest = new URLRequest(url);
request.method = URLRequestMethod.POST;//select the method as post
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handleComplete);
loader.load(request);//send the request with URLLoader()
function handleComplete(event:Event) {
var loader:URLLoader = URLLoader(event.target);
var vars:URLVariables = new URLVariables(loader.data);
//Access data from the PHP file
trace(vars.ip);
}
PHP:
<?php
$ip = $_SERVER[‘SERVER_ADDR’];
echo “ip=$ip”;
?>
When I test it it traces ::1
However if in the php file I change it to the following code I traces 1022545 as it should.
<?php
echo “ip=1022545”;
?>
I even tried to set the dataType in php:
<?php
$ip = $_SERVER[‘SERVER_ADDR’];
settype($ip,“string”);
echo “ip=”$ip";
?>
I’m not sure why it’s different. If anyone can help me with this one I would appreciate it.