Flash 執行PHP

語法跟Flash 外部載入文字檔 大同小異,但多加了要傳參數

AS2.0

var loader:LoadVars=new LoadVars();
loader.load("http://localhost/xxx.php?acc=a&pwd=b");
loader.onData=function(re:String){
trace(re);
}

AS3.0

var myURLReq:URLRequest = new URLRequest();
myURLReq.url="http://localhost/xxx.php?acc=a&pwd=b";
var myURLLoader:URLLoader = new URLLoader();
myURLLoader.load(myURLReq);
myURLLoader.addEventListener(Event.COMPLETE, function(e:Event){
trace(myURLLoader.data);
});


php

$account= $_GET['acc'];
$password= $_GET['pwd'];
echo "a1=".$account;
echo "p1=".$password;

範例檔:
AS2.0 http://www.box.net/shared/5suo5kcva8
AS3.0 http://www.box.net/shared/qn4ityqo1n
PHP http://www.box.net/shared/i3vyy6urs7

0 意見: