FLEX 与现有开发语言的通信全面解析
以下介绍几种最为常见和实用的FLEX与现有开发语言通信的方法:
1.C#
2.PHP
3.JAVA
1.Flex与C#通信(.net开发中常用)
Flex端代码:
public static function SendMessage(objXML:XML,objResultHandle:Function):void
{
var objHttpService:HTTPService = new HTTPService();
objHttpService.url = "http://localhost:8085/upfiledata.aspx"; //发送到的C#页面
objHttpService.resultFormat = "e4x";
objHttpService.addEventListener(ResultEvent.RESULT,objResultHandle);
objHttpService.method = "POST";
objHttpService.contentType = "application/xml";
objHttpService.send(objXML); //objXML 要发送的数据
}
public function objResultHandle(evt:ResultEvent):void
{
evt //接收到的数据
}
C#端:
protected void Page_Load(object sender, EventArgs e)
{
XmlDocument objProtocolDom = new XmlDocument();
objProtocolDom.Load(Request.InputStream); //objProtocolDom接收来自Flex端所发送的数据流
Response.ContentType = "text/xml";
Response.Write(objResultDom.OuterXml); //向Flex端下发数据流
}
2.Flex与php通信
Flex代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.co
相关文档:
测试文件代码如下:导入com.hillelcoren.components包
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:hc="com.hillelcoren.components.*"
xmlns:classes="com.hillelcoren.components.autoComplete.classes.*"
xmlns:l ......
1、XMLSocket对象简介
在概述里,已经提到过了Flash里的XMLSocket对象,它是实现Falsh和服务器Socket间
通信的核心。它允许包含Flash应用的浏览器与服务端建立socket连接,之后Flash应用与服务端就可以相互发送XML数据,而且在一个
socket连接建立之后,在该连接上传送的数据量是没有限制的,直到socket连接关闭。XMLSoc ......
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
viewSourceURL="srcview/index.html" backgroundColor="0x000000" layout="absolute">
<mx:Script>
&nb ......
<mx:DataGrid id="dg" click="select()" dataProvider= "{modelLocator.resultList}" borderStyle="none"
verticalGridLines="false" horizontalGridLines="false" verticalScrollPolicy="off" rowCount="10"
fontSize="16" fontStyle="normal" fontThickness="0" width="100%" height="100%">
<mx:columns& ......
<?xml version="1.0"?>
<!-- Simple example to demonstrate the Alert control. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script& ......