欢迎提出一些建议。这是我在输出中的错误...ArgumentError: Error #2126: NetConnection
对象必须连接在flash.net::NetStream/ctor()
at flash.net::NetStream()
。这让我疯狂!我一直在调整我的代码,但仍然无法弄清楚。以下是我的代码,我不会向您展示它太长:如果您能确定我哪里出错了。
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netHandler);
nc.connect("rtmfp://localhost/appName");
function netHandler(event:NetStatusEvent):void{
switch(event.info.code){
case "NetConnection.Connect.Success":
trace("connecting.....");
break;
case "NetConnection.Connect.Failed":
trace("Unable to connect up");
break;
case "NetConnection.Connect.Rejected":
trace("Whoops");
break;
}
}
var ns:NetStream = new NetStream(nc);
ns.publish("live", "recording");
var cam:Camera = Camera.getCamera();
cam.setMode(540, 320, 15);
cam.setQuality(0, 80);
ns.attachCamera(cam);
cam.addEventListener(StatusEvent.STATUS, statusHandler);
var vid:Video = new Video();
vid.width = cam.width;
vid.height = cam.height;
vid.attachCamera(cam);
var mic:Microphone = Microphone.getMicrophone();
mic.setSilenceLevel(0, 2000);
mic.framesPerPacket = 1;
mic.codec = SoundCodec.SPEEX;
mic.gain = 50;
ns.attachAudio(mic);