title: ActionScript code error issue in Flash cs6
body: <p>Some advice would be welcome. This, is my error in the output...<code>ArgumentError: Error #2126: NetConnection</code> object must be connected  at <code>flash.net::NetStream/ctor()</code> at <code>flash.net::NetStream()</code>. 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.</p>
  
  <pre><code> 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);
  </code></pre>