Runtime argument error in Flash AS3

Hello Guys, I really need some advice. I am attempting to stream my webcam using AS3 code but I keep receiving this annoying error message in the output panel when I execute the code:


ArgumentError: Error #2126: NetConnection object must be connected.
 at flash.net::NetStream/ctor()
 at flash.net::NetStream()
 at Untitled_fla::MainTimeline/frame1()
Connecting............

At first I listen for the NetStatus listener and the connection succeeds. However, when I add the NetStream to the code I keep getting that error:(
Well this is my code below: Any ideas how I can fix this? Its driving me insane!

import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.net.NetStream;
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.connect("rtmfp://localhost/streamCam");
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatus);

function netStatus(event:NetStatusEvent):void{
 switch(event.info.code){
  case "NetConnection.Connect.Success": 
  trace("Connecting............");
  break;
  
  case "NetConnection.Connect.Failed":
  trace("Unable to Connect to FMS");
  break;
  
  case "NetConnection.Connect.Rejected":
  trace("Ouch!!!");
  break;
  
  ns.publish("myStream");
 }
}

import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.net.NetStream;
import flash.media.Camera;
import flash.events.StatusEvent;
import flash.media.Video;
import flash.media.Microphone;
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.connect("rtmfp://localhost/streamCam");

function netStatus(event:NetStatusEvent):void{
 switch(event.info.code){
  case "NetConnection.Connect.Success": 
  trace("Connecting............");
  break;
  
  case "NetConnection.Connect.Failed":
  trace("Unable to Connect to FMS");
  break;
  
  case "NetConnection.Connect.Rejected":
  trace("Ouch!!!");
  break;
  
 
 }
}
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
var cam:Camera = Camera.getCamera();
cam.setMode(500,300, 15);
cam.setQuality(0, 80);
ns.attachCamera(cam);
cam.addEventListener(StatusEvent.STATUS, statusHandler);
var vid:Video = new Video();
vid.height = cam.height;
vid.width = cam.width;
vid.attachCamera(cam);
addChild(vid);
var mic:Microphone = Microphone.getMicrophone();
mic.framesPerPacket = 1;
mic.gain = 50;
mic.setSilenceLevel(0, 2000);
mic.codec = SoundCodec.SPEEX;
ns.attachAudio(mic);
mic.addEventListener(StatusEvent.STATUS, micStatus);
function statusHandler(event:StatusEvent):void 
{ 
    switch (event.code) 
    { 
        case "Camera.Muted": 
            trace("User clicked Deny."); 
            break; 
        case "Camera.Unmuted": 
            trace("User clicked Accept."); 
            break; 
    } 
}
 
function micStatus(event:StatusEvent):void 
{ 
    if (event.code == "Microphone.Unmuted") 
    { 
        trace("Microphone access was allowed."); 
    }  
    else if (event.code == "Microphone.Muted") 
    { 
         trace("Microphone access was denied."); 
    } 
}