close
as3.0 php for flash 傳接值過程隴長 就不贅述 . 請看以下Code

    這裡注意,flash使用第1,2種做傳值時, 有時候會接到舊的參數,
    那是因為你取到的是暫存頁面, 所以在接口網頁我們會強迫去
    取最新頁面, 在網址列後面加任意變數與隨機的值如下:

    new URLRequest("http://receive.php?aa= " + Math.random()   );
  

<---------------------------  接值部份  -------------------------->


var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
var request:URLRequest = new URLRequest("http://receive.php");
var variables:URLVariables = new URLVariables(); 
request.data = variables;
loader.load(request);

function completeHandler(e:Event):void
{

    var returnData:String = e.target.data;
    //此時的 returnData 就是從 php 網頁上接過來的全部內容  可以利用 split 拆特殊符號進行分解
}



<--------------------------- 傳值部份 ----------------------------->
//傳值部份分為 3 種 :
    1.用於紀錄遊戲內容參數(不另開視窗,在背景默默的做)
    2.另開視窗紀錄參數(屬較穩定傳值法) 是接值也是傳值
    3.在網址後面加參數來傳遞變數




<---------------------------  第 1 種 ----------------------------------->
            var request:URLRequest=new URLRequest("http://trans.php");
            var variables:URLVariables = new URLVariables();
            variables.name ="abc" ;
            request.data=variables;
            variables.nocache = new Date().getTime();
            request.method=URLRequestMethod.POST;
            sendToURL(request);

<--------------------------- 第 2 種 ------------------------------------>

            在網頁中的flash 標籤中嵌入值

             flashvars" value="param= echo $_REQUEST['num'] ?>" />

             當外部另開視窗 送出目標  html?num=123;
             $_REQUEST['num'] 此時就會接到 123值

             在該頁內容下的 flash 內部
             則可以利用  this.stage.loaderInfo.parameters.param 接 param 值


<--------------------------- 第 3 種 ------------------------------------>


            很普遍的作法, 就拿現在無名小站上方網址列來說
             http://www.wretch.cc/blog/post.php?blog_id=u2420123  

            blog_id 就是變數 後面就是你要傳遞的值
            而接法如第2點

            stage.loaderInfo.parameters["blog_id"]
                 
arrow
arrow
    全站熱搜

    u2420123 發表在 痞客邦 留言(7) 人氣()