调了很久才发现在flex 2中不用设置amf的版本,而且服务器端amfphp是1.2.5或1.9都行得通。如果是amfphp1.9的话,还可以省去methodTable定义。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">
<mx:TextArea id="amfphptest" width="200"/>
<mx:Button label="call amfphp" click="callAmfPHP(amfphptest.text)" />
<mx:Script>
<![CDATA[
import flash.net.Responder;
import flash.net.NetConnection;
private var gateway_url:String = "
http://www.flashxm.com/amfphp/gateway.php";
private var geteway_conn:NetConnection = new NetConnection();
public function callAmfPHP(str:String):void
{
geteway_conn.connect(gateway_url);
geteway_conn.call("HelloWorld.phpSay", new Responder(onResult, onFault), str);
}
private function onResult(result:Object):void
{
amfphptest.text = result.toString();
}
private function onFault(fault:String):void
{
amfphptest.text = fault;
}
]]>
</mx:Script>
</mx:Application>
其中mx:Script部分简直就等于flash actionscript!
此信息来自〖闪无忧〗
查看原网址:http://www.5uflash.com/Html/flex/10395766.html