<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#FFFEEE"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.formatters.DateFormatter;
private var srvurl:String = "rtmp://localhost/flex";
private var nc:NetConnection;
private var responder:Responder;
private var inst:String;
private var outst:String;
private var mystring:String
private function init():void
{
inst = "ml";
outst = "mj";
nc = new NetConnection();
nc.connect(srvurl);
nc.client = this; //指示应对其调用回调方法的对象, 设置为this后, Server端call的就是this中定义的方法
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
}
private function onNetStatus(event:NetStatusEvent):void
{
nc.call("MSGChange",null,inst+outst);
Alert.show("视频请求已发出请等待。。。。");
}
public function MSGChange(obj:Object):String
{
Alert.show(obj.toString());
mystring = obj.toString();
var a = mystring.indexOf("mj");
if(a){
Alert.show(mystring);
}
//lblSrvNotice.text = obj.toString();
return "I just want to begin";
}
]]>
</mx:Script>
</mx:Application>
asc文件如下:
application.onAppStart = function()
{
};
application.onConnect=function(newClient){
trace("hhhhhhh");
application.acceptConnection(newClient);
}
Client.prototype.MSGChange=function(msg){
application.broadcastMsg("MSGChange",msg);
}
application.onDisconnect = function(currentClient)
{
//When currentClient leaves put the element back in array
//vidStreams.push(currentClient.cliNow);
}