Flex与HTPPService,Flex与php的交互
上一篇 /
下一篇 2008-01-06 20:03:27
/ 个人分类:Flex
//-----------------website.mxml--------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="264" height="228" >
<mx:scrīpt source="website.as" />
<mx:HTTPService id="checklogin" url="http://localhost/flex.php" method="post" result="loginResult(event)" fault="err(event)" />
<mx:TextInput x="52" y="55"/>
<mx:Button x="95" y="85" label="login" id="login" click="initApp()" />
</mx:Application>
//----------website.as脚本内容-------------------------------------------------------
import mx.rpc.events.ResultEvent;//
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
//点击login按钮时候响应的事件:调用id为checklogin的httpservice的send函数发送post请求给flex.php
public function initApp():void
{
checklogin.send();
}
//通过一个对话框显示post请求返回来的结果。
public function loginResult(evt:ResultEvent):void
{
Alert.show("result: "+evt.result.toString());
}
//通过一个对话框显示post请求出错后返回来的结果。
public function err(evt:FaultEvent):void
{
Alert.show("error: "+evt.fault.toString());
}
//flex.php
//在flex.php里面写点代码随便输出一句话就可以了。
//比较简单,主要用来明白怎么在flex中使用httpservice来与php交互。
导入论坛
收藏
分享给好友
管理
举报
TAG:
flex
Flex