Some advice would be welcome. This, is my error in the output...ArgumentError: Error #2126: NetConnection
object must be connected at flash.net::NetStream/ctor()
at flash.net::NetStream()
. Its driving me crazy! I have been tweaking my code but still cannot figure it out.
Following is my code I wont show you it all its too long: If you can identify where I am going wrong.
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);