Flash -> PHP

it drives me crazy !!!

i’m not able to get into my PHP the variables from Flash.
more… i’m not able to run the PHP page asa normal page on server… it’s like nothing works :frowning:

here is my AS3 code :


import flash.external.*;

myButton.addEventListener("click", sendData2PHP);

//var link2:String = "http://192.160.1.2/test/flashdataexchange.php";
var link:String = "http://192.160.1.2/test/DataExchangeResult.php";


var request:URLRequest = new URLRequest (link);
var loader:URLLoader = new URLLoader (request);                    

var variables:URLVariables = new URLVariables();
request.method = URLRequestMethod.POST;
request.data = variables;

var curUrl:String =  String( ExternalInterface.call(" function(){ return document.location.href.toString();}"));

function sendData2PHP(evt:Event):void
{
    variables.lg = myField1.text;
    variables.address = myField2.text;            
    variables.field2 = curUrl;
    
    loader.addEventListener(Event.COMPLETE, onComplete);
    loader.addEventListener(IOErrorEvent.IO_ERROR, sendIOError );
    loader.dataFormat = URLLoaderDataFormat.TEXT;
    loader.load(request);
}

function onComplete (event:Event):void
{
    Text1.text = event.target.data;
}

here is the code of my DataExchangeResult.php file:


<html>
<head>
</head>
<body>
<?php
    $lg=$_POST['lg'];
    $ad=$_POST['address'];
    $f2=$_POST['field2'];
    echo "test : ".$ad ;
?>
</body>
</html>

and here is the code of my FlashDataExchange.php file :


<html>
<head>
</head>
<body>
<?php
    echo "-- POST -- <br>";
    echo "Lg : ".$_POST['l']."<br>";
    echo "Address : ".$_POST['address']."<br>";
    echo "f2 : ".$_POST['f2']."<br>";
    echo "<br>-- GET -- <br>";
    echo "Lg : ".$_GET['l']."<br>";
    echo "Address : ".$_GET['address']."<br>";
    echo "f2 : ".$_GET['f2']."<br>";
?>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="400" height="200" id="FlashdataExchange" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="allowFullScreen" value="false" />
    <param name="movie" value="FlashdataExchange.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#006600" />    <embed src="FlashdataExchange.swf" quality="high" bgcolor="#006600" width="400" height="200" name="FlashdataExchange" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </object>
</body>

</html>

As you can see i tried several type of passing parameters GET or POST… but without success…

how is it possible that i do not get variables value from Flash into my “DataExchangeResult.php” file ?

thanks a lot,
A