Flex 3 使用 Red5 和 RSO 进行資料交換

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” width=”343″>
<mx:Script>
<![CDATA[
import com.live.spaces.chuiwenchiu.net.MyNetConnection;
public var conn:MyNetConnection = new MyNetConnection();
public var so:SharedObject = null;
private  function btnStart_click():void{
conn.addEventListener(NetStatusEvent.NET_STATUS, function onStatus(e:NetStatusEvent):void{
if (e.info['code'] == “NetConnection.Connect.Success”){
so = SharedObject.getRemote(”SampleChat”, conn.uri, false);
so.addEventListener(AsyncErrorEvent.ASYNC_ERROR, function(e:AsyncErrorEvent):void{
var msg:String = e.error.message;
});
so.addEventListener(SyncEvent.SYNC, function(e:SyncEvent):void{
if (so.data["SampleChat"] == undefined){
return;
}
txtData.text += so.data["SampleChat"] + ‘\n’;
});
so.connect(conn);
btnSend.enabled = true;
}else{
trace(e.info['code']);
}
});
conn.connect(”rtmp://localhost/SOSample”);
}
private function btnSend_click():void{
if (txtMsg.text.length == 0){
return;
}
so.setProperty(”SampleChat”, txtMsg.text);
}
]]>
</mx:Script>
<mx:Button x=”23″ y=”10″ label=”Connect” click=”btnStart_click()” />
<mx:Button id = “btnSend” x=”218″ y=”229″ label=”Send” enabled=”false” click=”btnSend_click()”/>
<mx:TextArea x=”23″ y=”40″ id=”txtData” width=”187″ height=”181″/>
<mx:TextInput x=”23″ y=”229″ width=”187″ id=’txtMsg’/>
</mx:Application>

你可能感兴趣的:(Flex)