如何从actionscript3设置$ _POST或$ _REQUEST等参数?

时间:2013-02-23 12:49:07

标签: php actionscript-3 flash web

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

我想从flash文件中设置$_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)

我该怎么做? 感谢

1 个答案:

答案 0 :(得分: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)