AS3:
main.as
var _connetction :connetction = new connetction()
_connetction.act()
connetction.as
package {
import flash.net.NetConnection;
import flash.net.*;
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
public class connetction {
private var nc = new NetConnection();
public function act():void {
nc.objectEncoding = ObjectEncoding.AMF0;
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://192.168.2.43/test");
}
private function netStatusHandler(event:NetStatusEvent):void {
trace(event.info.code);
switch (event.info.code) {
case "NetConnection.Connect.Success" :
trace("连接成功!");
nc.call("sendmsg",null);
break;
}
}
}
}
FMS2:
main.asc:
application.onConnect = function(client) {
application.acceptConnection(client); //同意这个客户端调用服务端函数
client.sendmsg = function() {
var s =0
for(var i=0;i<100;i++){
s+=i
}
trace(s);
};
};