Argument error #2126

Hello Guys, I would appreciate some advice. I am
trying to connect to my [FONT=Verdana][SIZE=2][COLOR=#0000ff]webcam[/COLOR][/SIZE][/FONT]
but I keep receiving this error message argument error#2126

I have been tweaking around my code for hours but problem keeps persisting. I don’t know where is the problem?
This is my code below:

Thanks in advance

ArgumentError: Error #2126: NetConnection object
must be connected.

at flash.net::NetStream/construct()

at [COLOR=blue][COLOR=blue !important][FONT=verdana][COLOR=blue !important][FONT=verdana]flash[/FONT][/COLOR][/FONT][/COLOR][/COLOR].net::NetStream()

Here
is my code:

//Establishing a FMS connection
var nc:NetConnection = new
NetConnection();

nc.addEventListener(NetStatusEvent.NET_STATUS,
netHandler);

nc.connect("rtmfp://localhost/myAppName);

function
netHandler(event:NetStatusEvent):void{

switch(event.info.code)

case
“NetConnection.Connect.Success”:

trace(“Connecting
up”);

break;

case
“NetConnection.Connect.Failed”:

trace(“Unable to
Connect”);

break;

case
“NetConnection.Connect.Rejected”:

trace(“Ouch”);

break;

var
ns:NetStream = new NetStream(nc);

ns.publish(“live”,
“streaming”);

var cam:Camera =
Camera.getCamera();

cam.setQuality(0, 80);

cam.setMode(500, 300,
15);

ns.attachCamera(cam);

cam.addEventListener(StatusEvent.STATUS,
statusHandler);

var vid:Video = new [COLOR=blue][COLOR=blue !important][FONT=verdana][COLOR=blue !important][FONT=verdana]Video[/FONT][/COLOR][/FONT][/COLOR][/COLOR]();

vid.height
= cam.height;

vid.width =
cam.width;

vid.attachCamera(cam);

addChild(vid);

var
mic:Microphone = Microphone.getMicrophone();

mic.setSilenceLevel(0,
2000);

mic.framesPerPacket = 1;

mic.[COLOR=blue][COLOR=blue !important][FONT=verdana][COLOR=blue !important][FONT=verdana]codec[/FONT][/COLOR][/FONT][/COLOR][/COLOR]
= SoundCodec.SPEEX;

mic.gain =
50;

ns.attachAudio(mic);

mic.addEventListener(StatusEvent.STATUS,
micStatus);

////Verifying that the cameras are installed
if (cam
== null)
{
trace(“User has no cameras installed.”);
}
else
{

trace(“User has at least 1 camera installed.”);
}

//Detecting
permission for camera access
function statusHandler(event:StatusEvent):void

{
switch (event.code)
{
case “Camera.Muted”:
trace(“User
clicked Deny.”);
break;
case “Camera.Unmuted”:
trace(“User clicked
Accept.”);
break;
}
}

//Camera lists names
for (var i:int
= 0; i < Camera.names.length; i++)
{
trace(Camera.names*);
}

//microphone event
function
micHandler(event:StatusEvent):void
{
if (event.code ==
“Microphone.Unmuted”)
{
trace(“Microphone access was allowed.”);
}

else if (event.code == “Microphone.Muted”)
{
trace(“Microphone
access was denied.”);
}
}