伊莉討論區

標題: flash前台輸入資料php後台計算在傳回到前台的問題 [打印本頁]

作者: nightgossoon    時間: 2014-1-25 10:51 AM     標題: flash前台輸入資料php後台計算在傳回到前台的問題

小弟目前在讀"FLASH+PHP資料庫網站開發設計"
裡面有個範例是在flash介面輸入文字'a'跟'b'然後利用$_GET的方法傳給php的檔案做加法
但是傳回來卻不會顯示到flash的動態文字上請問我該如何修改程式碼??
a_txt.text = b_txt.text = c_txt.text = '';
var ur:URLRequest = new URLRequest('a_plus_b.php');
ur.method = URLRequestMethod.GET;

var ul:URLLoader = new URLLoader();
c_btn.addEventListener(MouseEvent.CLICK, doPlus);
ul.addEventListener(Event.COMPLETE, loadComplete);

function doPlus(ev:MouseEvent):void
{
        var vars:URLVariables = new URLVariables  ;
        vars.a = a_txt.text;
        vars.b = b_txt.text;
        ur.data = vars;
        ul.load(ur);
}

function loadComplete(ev:Event):void
{
        var vars:URLVariables = new URLVariables(ul.data);
        c_txt.text = vars.c;
}a_txt.text = b_txt.text = c_txt.text = '';
var ur:URLRequest = new URLRequest('a_plus_b.php');
ur.method = URLRequestMethod.GET;

var ul:URLLoader = new URLLoader();
c_btn.addEventListener(MouseEvent.CLICK, doPlus);
ul.addEventListener(Event.COMPLETE, loadComplete);

function doPlus(ev:MouseEvent):void
{
        var vars:URLVariables = new URLVariables  ;
        vars.a = a_txt.text;
        vars.b = b_txt.text;
        ur.data = vars;
        ul.load(ur);
}

function loadComplete(ev:Event):void
{
        var vars:URLVariables = new URLVariables(ul.data);
        c_txt.text = vars.c;
}a_txt.text = b_txt.text = c_txt.text = '';
var ur:URLRequest = new URLRequest('a_plus_b.php');
ur.method = URLRequestMethod.GET;

var ul:URLLoader = new URLLoader();
c_btn.addEventListener(MouseEvent.CLICK, doPlus);
ul.addEventListener(Event.COMPLETE, loadComplete);

function doPlus(ev:MouseEvent):void
{
        var vars:URLVariables = new URLVariables  ;
        vars.a = a_txt.text;
        vars.b = b_txt.text;
        ur.data = vars;
        ul.load(ur);
}

function loadComplete(ev:Event):void
{
        var vars:URLVariables = new URLVariables(ul.data);
        c_txt.text = vars.c;
}


php如下:
<?php
$c = $_GET['a']+$_GET['b'];
echo "c=$c";
?>

作者: good-jack    時間: 2014-8-3 12:13 PM

echo "c=$c";
這樣整個都是字串吧
試試 echo $c;




歡迎光臨 伊莉討論區 (https://attach1201.eyny.com/) Powered by Discuz!