如何从flex运行php文件(mxml / actionscript?

时间:2014-02-28 16:51:33

标签: php flex actionscript mxml

如何从我的flex应用程序中执行另一个文件中的php代码?

我想要执行的PHP代码(漂亮而简单)

 <?php
     echo "My first PHP script!";
 ?>

所以我希望以上执行。到目前为止,我在我的flex应用程序中有这个:

 <mx:HTTPService id="userRequest" url="C:\Users\blah\blah\blah\src\ItemTableService.php" useProxy="false" method="POST">

    </mx:HTTPService>
</fx:Declarations>
<mx:Button label="Submit" click="userRequest"/>

所以我现在正在本地运行它。我认为需要点击&#34;点击 - &#34; userRequest。(某事)&#34; /&gt;但不确定它需要什么。

1 个答案:

答案 0 :(得分:1)

我使用UrlLoader类

var url:String="example";
        var urlRequest:URLRequest=new URLRequest(url);
        urlRequest.method=URLRequestMethod.POST;
    //use variables only if yu need them    
var variables : URLVariables = new URLVariables();
        variables.something=ex;
        urlRequest.data=variables;
        var urlLoader:URLLoader=new URLLoader();
        urlLoader.addEventListener(Event.COMPLETE, onComplete);
        urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
        urlLoader.addEventListener(IOErrorEvent.IO_ERROR,onError);
        urlLoader.load(urlRequest);

首先尝试你的浏览器,你的浏览器是否可以获得正确的URL,它应该是localhost或127.0.0.1之类的

http://localhost/myscript.php

编辑为Josh在评论中建议您必须安装并安装支持PHP的Web服务器。

相关问题