1

我正在尝试与 Flash 中的 php 文件进行通信。

我想$_REQUEST['setData']= "true"从闪存文件中设置。这是我的php代码。

<?php
if($_REQUEST['setData']=="true")
{
    echo "setData";
}
?>

到目前为止我在 actionscript3 代码中的内容 -

        var phpVars:URLVariables = new URLVariables();
        var phpFileRequest:URLRequest = new URLRequest("php/index.php");
        phpFileRequest.method = URLRequestMethod.POST;
        phpFileRequest.data = phpVars;

        var phpLoader:URLLoader=new URLLoader();
        phpLoader.addEventListener(Event.COMPLETE, showResult);
        phpLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityError);
        phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioError);
        phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

        phpVars.email = email.text;
        phpVars.password = password.text;

        phpLoader.load(phpFileRequest)

我怎样才能做到这一点?谢谢

4

1 回答 1

2

只是从阅读您的代码,不了解 AS,我猜这里

    var phpVars:URLVariables = new URLVariables();
    var phpFileRequest:URLRequest = new URLRequest("php/index.php");

    phpVars.email = email.text;
    phpVars.password = password.text;
    phpVars.setData= 'true';//**************** LOOK HERE!!!!!!!!!!!!!!!!!!

    phpFileRequest.method = URLRequestMethod.POST;
    phpFileRequest.data = phpVars;

    var phpLoader:URLLoader=new URLLoader();
    phpLoader.addEventListener(Event.COMPLETE, showResult);
    phpLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityError);
    phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;


    phpLoader.load(phpFileRequest)
于 2013-02-23T13:29:20.297 回答