http://www.cnblogs.com/beniao/category/190537.html
import flash.net.NetConnection;
import flash.events.NetStatusEvent;import flash.net.Responder;
var nc:NetConnection = new NetConnection();
var rp:Responder = new Responder(onSuccess,onFail);
nc.connect("rtmp://localhost/firstFmsApp");
nc.call("sayHelloWorld",rp,"World");
nc.client = this ;
nc.addEventListener(NetStatusEvent.NET_STATUS,onStatus);
function onStatus(e:NetStatusEvent):void{
trace(e.info.code);
}
function onSuccess(e:Object):void{
trace("Success:" +e.toString());
}
function onFail(e:Object):void{
trace("Fail:"+ e.description());
}
===============================
在application下的文件夹(程序)中简历main.asc文件(用来交互?),内容:
application.onConnect = function(client)
{
client.sayHelloWorld = function (str)
{
return "I can say hello :" + str ;
}
this.acceptConnection(client);
}
======================================
client.后头的应该是函数,str是参数,与上面定义的call函数中的第一个和第三个参数一致;第二个参数是responder对象,responder对象有两个参数,均是函数,分别是成功连接和连接失败时调用。
nc,添加函数侦听器 NetStatusEvent.NET_STATUS,显示连接的情况。
====================================
结果输出:
NetConnection.Connect.Success
Success:I can say hello :World