Flex Socket 与 C# 通信
Flex端代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
>
<fx:Script>
<!--[CDATA[
import mx.controls.Alert;
/////////////////////////////////
//private member
private var xmlsocket:XMLSocket= new XMLSocket();
private var alert:Alert;
private var tmpStr:String;
/////////////////////////////////
//连接服务器
private function ConncetServer():void
{
xmlsocket.addEventListener(DataEvent.DATA,OnRecived);
xmlsocket.addEventListener(Event.CONNECT , onConnected);
this.xmlsocket.connect(this.txtIP.text,int(this.txtPort.text));
}
private function onConnected(evt:Event):void
{
xmlsocket.send(this.txtTrueName.text+" has connected");
this.txtContent.text=this.txtContent.text+"连接成功\n";
}
//发送信息
private function Send():void
{
this.xmlsocket.send(this.txtTrueName.text+"|"+this.txtSendContent.text+"\n");
}
//接收数据
private function OnRecived(event:DataEvent):void
{
trace("等待读取数据信息");
tmpStr = event.text;
//alert=Alert.show("收到新消息","消息");
this.txtContent.text=this.txtContent.text+"\n"+tmpStr;
}
]]-->
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Panel right="0" left="0" top="0" bottom="0" horizontalCenter="left">
<mx:TextInput borderColor="#070D04" borderStyle="inset" id="txtIP" text="192.168.1.99" left="88" top="23"/>
<mx:TextInput borderColor="#070D04" borderStyle="inset" width="94" id="txtPort" text="6666" left="293" top="23"/>
<mx:TextInput borderColor="#070D04" borderStyle="inset" width="94" id="txtTrueName" t
相关文档:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<!--[CDATA[
import mx.rpc.ev ......
flex中在DisplayObject里直接用stage,可能会是null,原因不是太清楚,找到了解决办法,当接收到ADDED_TO_STAGE事件时,stage肯定被创建出来了,这个时候再使用就没有问题。
addEventListener( Event.ADDED_TO_STAGE, function( e:Event ):void ??
{
stage.addEventListener(KeyboardEvent.KEY_DO ......
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script><!--[CDATA[import mx.collections.ArrayCollection;
public var a1:ArrayCollection = new ArrayCollection ([{ Region:"Region1",Territory:"Territory1",Ter ......
使用flex tree 和list实现如下选择用户的效果
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
showCloseButton="true" creationComplete ......
最近遇到了flex 的安全沙箱问题,找了很多资料发现不是都是和我,我的程序需要socket连接,而大多数讲的都是跨域文件读取的。我先把两种方法都总结出来:
跨域文件读取
方法一:在目标服务器上布署crossdomain.xml文件(我用的此方法很管用,放上就没问题了) 需要远程服务根目录定义有crossdomain.xml文件,如下:
<?x ......